多文件封装.txt $v) { if($v==0){ $onefile['name'] =$file['name'][$k]; $onefile['tmp_name'] =$file['tmp_name'][$k]; $onefile['size'] =$file['size'][$k]; $onefile['error'] =$file['error'][$k]; $onefile['type'] =$file['type'][$k]; if(!is_u
$v) { if($v==0){ $onefile['name'] =$file['name'][$k]; $onefile['tmp_name'] =$file['tmp_name'][$k]; $onefile['size'] =$file['size'][$k]; $onefile['error'] =$file['error'][$k]; $onefile['type'] =$file['type'][$k]; if(!is_uploaded_file($onefile['tmp_name'])){ die('非法文件'); } $finfo=finfo_open(FILEINFO_MIME_TYPE); $mime=finfo_file($finfo,$onefile['tmp_name']); if(!empty($arr_mime)){ if(in_array($mime,$arr_mime)){ die('类型不支持'); } } if($max_size*1024*1024<$onefile['size']){ die('文件过大'); } $ext=strrchr($onefile['name'],'.'); $save_path=$dir.uniqid().$ext; if(move_uploaded_file($onefile['tmp_name'],$save_path)){ echo "文件".$onefile['name']."上传成功! 保存路径".$save_path.""; } } } } else{ if($file['error']!=0){ $error_msg=""; switch ($file['error']) { case 1: $error_msg='文件超过2M'; break; case 4: $error_msg='未选择文件'; break; case 6: $error_msg='临时路径错误'; break; } die($error_msg); } } } $max_size=1.8; $file=$_FILES['myfile']; $dir="f:/image/"; $arr_mime=["image/png,image/gif,image/jpeg,image/jpg,text/html,text/css,text/javascript,text/plain"]; echo upload_one($file,$max_size,$dir,$arr_mime); ?>