사이트 내 전체검색
PHP
파일 업로드 생성 함수
로빈아빠
https://cmd.kr/php/360 URL이 복사되었습니다.

본문

function upload_file2($dir, $file_name, $file)
{
 $img_date       = date("Ymdhis");
 $cnt   = rand(0, 10000);

 $temp = split("\.", strtolower($file_name));
 $ext = $temp[count($temp) - 1];

 $ext_able = "gif jpg png zip alz rar txt doc hwp psd xls ppt bmp sql avi mpeg asf wmv wma pdf flv swf mp4 mp3 xlsx pdfx pptx";

 if (!eregi($ext, $ext_able)) error("등록 가능한 파일 형식이 아닙니다.");

 $file_name = $img_date . "_" . $cnt . substr($file_name, strrpos($file_name, "."));

 while (file_exists($dir . $file_name))
 {
  $cnt   = rand(0, 100000);
  $file_name = $img_date . "_" . $cnt . substr($file_name, strrpos($file_name, "."));
 }

 move_uploaded_file($file, $dir . $file_name);
 return $file_name;
}

댓글목록

등록된 댓글이 없습니다.

PHP
871 (11/18P)

Search

Copyright © Cmd 명령어 3.145.91.70