파일 업로드 클래스 정보
파일 업로드 클래스본문
{
function getFile($files, $n=0)
{
global $FILE_UPLOAD_DIR;
return $this->getFileA($files, $FILE_UPLOAD_DIR, $n);
}
function getFileA($files, $dir, $n=0)
{
$arr=array();
$fileName = preg_replace("/.[^.]*$/i", "", $files['name']);
$fileExt = substr(strrchr($files['name'], "."), 1);
$filePath = $dir."/".$fileName.".".$fileExt;
$cnt = 0;
while(file_exists($filePath)){
$filePath = $fileName."[".(++$cnt)."].".$fileExt;
}
move_uploaded_file($files['tmp_name'][$n], $filePath);
chmod($filePath, 0777);
$arr['file_name'] = $files['name'][$n];
$arr['file_ext'] = $fileExt;
$arr['file_dir'] = $filePath;
$arr['file_size'] = $files['size'][$n];
$arr['file_bigo'] = $files['type'][$n];
return $arr;
}
function getFiles($files)
{
global $FILE_UPLOAD_DIR;
return $this->getFilesA($files, $FILE_UPLOAD_DIR);
}
function getFilesA($files, $dir)
{
$arr = array();
for($i = 0; $i < count($files); $i++)
{
$arr[] = $this->getFileA($files, $dir, $i);
}
return $arr;
}
}
0
댓글 1개
업로드파일 클래스 정의