我正在使用下面的代码上传一些允许扩展名低于 5MB 的文件。但是使用此代码,所有 doc 或 pdf 等都没有上传!例如:4.78MB docx 文件或 windows phone 1.64 mb jpg 没有上传!
$allowedExts = array("gif", "jpeg", "jpg","png","pdf","doc","docx","txt","rtf","bmp","psd","zip","rar","ppt","pptx");
$extension = end(explode(".", $_FILES["file"]["name"]));
if (in_array($extension, $allowedExts) && $_FILES["file"]["size"]<5242880 && $_FILES["file"]["error"]<=0) {
$rand = rand(000,999);
$tempfile = $_FILES["file"]["name"];
$file = $time . "=" . $rand . "=" . $tempfile;
if(file_exists("upload/".$file)) {
header("location:home.php?error=error");
} else {
move_uploaded_file($_FILES["file"]["tmp_name"],"upload/".$file);
}
} else {
header("location:home.php?error=error"); //this gets executed for some doc or pdf files !
}