PHP: exif_imagetype() not working?

Posted by Karem on Stack Overflow See other posts from Stack Overflow or by Karem
Published on 2010-11-11T13:45:43Z Indexed on 2012/12/03 23:06 UTC
Read the original article Hit count: 172

Filed under:
|

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()

© Stack Overflow or respective owner

Related posts about php

Related posts about exif