Im trying to determine the mime type of an image:
$image = $_FILES['image']; //code shortened
function determineImage($imageResource){
$errors = array();
$types = array('gif' => IMAGETYPE_GIF,
'jpeg' => IMAGETYPE_JPEG,
'png' => IMAGETYPE_PNG,
'bmp' => IMAGETYPE_BMP);
if ( !in_array(exif_imagetype($imageResource['tmp_name']), $types )) {
$errors[] = 'Cannot determine mime type';
}
if ($imageResource['type'] !== 'image/gif' ||
$imageResource['type'] !== 'image/jpeg' ||
$imageResource['type'] !== 'image/pjpeg' ||
$imageResource['type'] !== 'image/png'){
$errors[] = 'Again cannot determine type';
}
return $errors;
}
I use
var_dump(determineImage($image));
this keep returning array(1) { [0]=> string(27) “Again cannot determine type” }
However this:
echo $image['type'];
just returns:
image/png
I’ve also got error_reporting(E_ALL) turned on. Can anyone make out what the problem is, have I made a silly mistake?
the code is a total random (the check doesn’t make sense at all)
by the way
AND not OR