我有问题。我的条件始终返回“必须填写所有字段”。我该怎么办?谢谢您的帮助...
if (! empty ($ _ FILES ['myFile'] ['name'])) {
$ fileImage = $ _FILES ['myFile'] ['name'];
$ extension = pathinfo ($ fileImage, PATHINFO_EXTENSION);
$ tmp_name = $ _FILES ["myFile"] ["tmp_name"];
if ((exif_imagetype ($ tmp_name) == 2) || (exif_imagetype ($ tmp_name) == 3)) {
$ userAvatar = $ _SESSION ['id']. '.' . $ Extension;
$ uploadDestination = "img / avatars /". $ Useravatar;
$ insertAvatar = $ db-> prepare ("UPDATE member SET avatar =? WHERE id =?");
$ insertAvatar-> execute (array ($ userAvatar, $ _SESSION ['id']));
move_uploaded_file ($ tmp_name, $ uploadDestination);
header ( 'Location: profil.php? id =' $ _ SESSION [ 'id'].)
} else {
$ error = 'This format is not taken into account!';
}
} else {
$ error = "All fields must be completed";
}
答案 0 :(得分:0)
您可以检查filesize($ some_file)是否大于0
答案 1 :(得分:0)
$ _ FILES始终具有
[file] => Array
(
[name] => MyFile.jpg
[type] => image/jpeg
[tmp_name] => /tmp/php/php6hst32
[error] => UPLOAD_ERR_OK
[size] => 98174
)
您可以使用以下内容获取尺寸
$_FILES['file']['size']