改为
if(move_uploaded_file($pic['tmp_name'], iconv("UTF-8","GBK",$upload_dir.$pic['name'])))
中文文件名需要转码成gbk:function saveFile($fileArr,$post_get){
$realFileName=$fileArr["name"]//上传文件的文件名
$ext_file_name=strrchr($realFileName, '.')?strrchr($realFileName, '.'):"" //获取扩展名
$type=$fileArr["type"]//上传文件的类型
$size=$fileArr["size"]//上传文件的大小
$tmp_name=$fileArr["tmp_name"]//上传文件的临时存放路径
$web_root=$_SERVER['DOCUMENT_ROOT']
//$guidFilePath=$web_root.stripslashes($post_get['tagPath']).'/'. creat_guid(0).$ext_file_name
$FileUrl=stripslashes($post_get['tagPath']).'/'. $realFileName.$ext_file_name
$FilePath=$web_root.$guidFileUrl
$FilePathBK=iconv("utf-8","gbk",$dFilePath)
$md5=strtoupper(md5_file($tmp_name))
try{
if (move_uploaded_file($tmp_name,$FilePathBK)){
return array("success"=>true, 'msg'=>"", "realFileName"=> $realFileName,"guidFilePath"=>$guidFilePath,'md5'=>$md5,"fileSize"=>$size)
}else{
return array("success"=>true, 'msg'=>$realFileName.' is not a valid upload file!', "realFileName"=> $realFileName,"guidFilePath"=>$guidFilePath,"fileSize"=>$size)
}
}catch (Exception $e){
return array("success"=>false, 'msg'=>$e->getMessage(),"realFileName"=> $realFileName,"guidFilePath"=>$guidFilePath,"fileSize"=>$size)
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)