PHP: exif_imagetype() not working?
- by Karem
I have this extension checker:
$upload_name = "file";
$max_file_size_in_bytes = 8388608;
$extension_whitelist = array("jpg", "gif", "png", "jpeg");
/* checking extensions */
$path_info = pathinfo($_FILES[$upload_name]['name']);
$file_extension = $path_info["extension"];
$is_valid_extension = false;
foreach ($extension_whitelist as $extension) {
if (strcasecmp($file_extension, $extension) == 0) {
$is_valid_extension = true;
break;
}
}
if (!$is_valid_extension) {
echo "{";
echo "error: 'ext not allowed!'\n";
echo "}";
exit(0);
}
And then i added this:
if (exif_imagetype($_FILES[$upload_name]['name']) != IMAGETYPE_GIF
OR exif_imagetype($_FILES[$upload_name]['name']) != IMAGETYPE_JPEG
OR exif_imagetype($_FILES[$upload_name]['name']) != IMAGETYPE_PNG) {
echo "{";
echo "error: 'This is no photo..'\n";
echo "}";
exit(0);
}
As soon when I added this to my imageupload function, the function stops working. I dont get any errors, not even the one i made myself "this is no photo", what could be wrong?
Just checked with my host. They support the function exif_imagetype()