【发布时间】:2017-03-26 15:23:07
【问题描述】:
clearstatcache();
if($_FILES['images']){
if ($_FILES['images']['error'] !== UPLOAD_ERR_OK) {
$error[] = "Upload failed with error code " . $_FILES['images']['error'];
}
$info = getimagesize($_FILES['images']['tmp_name']);
if ($info === FALSE) {
$error[] = "Unable to determine image type of uploaded file";
}
if (($info[2] !== IMAGETYPE_GIF) && ($info[2] !== IMAGETYPE_JPEG) && ($info[2] !== IMAGETYPE_PNG)) {
$error[] = "Not a gif/jpeg/png";
}
if ($_FILES["images"]["size"] > 100000) {//1mb limit
$error[] = "Sorry, your file is too large.";
}
}
这是我的 php 代码。检查文件是否为空。而且我要。如果文件存在,则 php 将检查文件图像。但是如果用户没有选择图像。验证将忽略它。我无法调试它。如果我没有选择图像代码仍然验证和错误说Warning: getimagesize(): Filename cannot be empty in C:\xampp\htdocs\savings\LiveUpdate.php on line 10
【问题讨论】:
-
编辑您的问题以包含 HTML 表单。您还应该谷歌该错误,它有很多命中,可能是由于很多原因。
标签: php