我刚刚工作,然后我认为我完成了,它停止工作。如果该文件不是图像,我试图让它发出错误。这里是我谈论的那部分。任何帮助将很乐意欣赏刚刚完成一个图像上传php mysql
$type_array = array('image/jpeg', 'image/gif', 'image/png','image/x-png'); //image types allowed
if(isset($_FILES['images'][$i]) and $_FILES['images']['name'][$i] != '') { //check image
if ($_FILES['images']['size'][$i] < 10240000) { //make sure file is larger than 10mb
$type = $_FILES['images']['type'][$i]; //get the file types
if (!in_array($type, $type_array)) { //make sure the images are allowed
$errors[] = "Please check that you are uploading an image.";
$show_errors = 'show';
exit;
}
} else {
$errors[] = "Please make sure each file is less than 10MB.";
$show_errors = 'show';
exit;
}
} //image checked
您的压痕是可怕的阅读。所以有什么问题?我不相信这是在那个代码段。 – j13r 2012-04-14 20:17:13
为什么有一组错误,然后在将一个值放入之后退出?另外,你的'$ show'变量是多余的 - 使用'if(count($ errors)){// Show Errors Here}'(或者如果你没有初始化它'if(isset($ errors)){。 ..}') – Basic 2012-04-14 20:23:26
它是如何“停止工作”?它允许各种文件吗? – 2012-04-14 20:24:14