/*
* @function 移动文件参数初始化
* @notice 初始化新文件名,新文件路径,检测与创建文件路径,构成最终全路径
*/
public function move_params_init(){
$newFileName=$this->createNewFileName();
$newFilePath=$this->getSequencePath($newFileName);
$this->createFileDir($newFilePath);
$this->destination=$newFilePath.$newFileName;
}
/*
* @function 创建新文件名
* @return string 新文件名
* @notice 文件名由 当前时间_随机数_毫秒数_文件类型.后缀名
*/
public function createNewFileName(){
list($usec,$sec)=explode(" ",microtime());
$new_file_name=date("YmdHis")."_".mt_rand(1000,9999)."_".substr($sec,2,5)."_".$this->file_category.".".$this->temp_fileExt;
return $new_file_name;
}
/*
* @function 获取序列化的文件路径
* @param $newFileName 新文件名
* @return string
*/
public function getSequencePath($newFileName){
$extension_dir=substr(md5($newFileName),0,1)."/".substr(md5($newFileName),1,1);//扩展目录
$path=$this->rootPath.$this->file_category;//固定目录
$sequence_path=$path."/".$extension_dir."/";
return $sequence_path;
}
/*
* @function 检测目录是否存在,不存在就创建
* @param $path目录
*/
public function createFileDir($path){
if(!is_dir($path)){
$tmp_path=dirname($path);
$this->createFileDir($tmp_path);
@mkdir($path,0777,true);
chmod($path,0777);
}
else{
return;
}
}
}
/*
$allow_type=array(
"image"=>array(
"png","jpeg","jpg","gif",
),
"file"=>array(
"rar","zip",
),
"video"=>array(
"avi","flv","wmv","mp4","vob","rmvb",
),
);
$allow_size=102400;
$rootPath="./upload/";
$fileUpload=new FileUpload($name,$allow_size,$allow_type,$rootPath);
$fileUpload->move_file();
*/
?>
各位大大们,帮忙看下,特别指出下有谁试过finfo_open这个函数没,因为PHP版本没有到5.3以上,所以无法对finfo_open函数做出测试。本人菜鸟一个。