Sunday, 25 August 2013

Uploading an image, fits the requirements but failes

Uploading an image, fits the requirements but failes

if(isset($_FILES['avatar']) && !empty($_FILES['avatar']['name'])){
if($_FILES['avatar']['type'] != "image/gif" ||
$_FILES['avatar']['type'] != "image/jpeg" || $_FILES['avatar']['type']
!= "image/jpg" || $_FILES['avatar']['type'] != "image/pjpeg" ||
$_FILES['avatar']['type'] != "image/x-png" ||
$_FILES['avatar']['type'] != "image/png"){
$errors[] = 'File does not have the right mime type.';
$errors[] = '(This avatar has the mime type '.
$_FILES['avatar']['type'] .')';
}
if($_FILES['avatar']['size'] > 40960){
$errors[] = 'File is too large, max 40 kb.';
$errors[] = 'This is '. $_FILES['avatar']['size'];
}
}
Hello again stackoverflow!
I let my users decide during registering if they want to upload their
avatar right away, or do it later.
What I'm currently trying is to upload a 800b gif file. But when
uploading, I get the error that the file does not match the allowed mime
types. What do I do here?

No comments:

Post a Comment