$f_type=strtolower("swf,rar,jpg,zip,7z,iso,gif,exe,rmvb");//设置可上传的文件类型
if (!is_uploaded_file($file) || ($_FILES['photoupload']['size'] > 20000 * 1024 * 1024) )
{
$error = 'Please upload only files smaller than 2Mb!';
}
$f_name=$_FILES['photoupload']['name'];
$tmp_type=substr(strrchr($f_name,"."),1);//获取文件扩展名
$tmp_type=strtolower($tmp_type);
if(!stristr($f_type,$tmp_type)){
$error="对不起,不能上传格式为:".$tmp_type."的文件:".$f_name;
}
if(move_uploaded_file($_FILES['photoupload']['tmp_name'], $uploadfile)){
$result['result'] = 'success';
$result['size'] =$f_name."文件上传成功";
}
else{
$result['result'] = 'failed';
$result['error'] =$f_name."上传失败";
}
温馨提示:答案为网友推荐,仅供参考