shinve — 2012-02-20T16:01:16-05:00 — #1
I use the following code:
$fileinfo = exif_imagetype($_FILES['file']['tmp_name']);
But this yields a fatal error: undefined function.
Can someone tell me what my error is here? (Using php 5.3.8)
php.net link: http://us3.php.net/manual/en/function.exif-imagetype.php
logic_earth — 2012-02-20T16:30:49-05:00 — #2
Its probably because you do not have the EXIF extension loaded in PHP.ini
rubble — 2012-02-20T17:15:13-05:00 — #3
Put this on a page of its own and load the page; it should show all your php info and wether the EXIF extension is installed.
<?php phpinfo() ?>
shinve — 2012-02-20T18:54:45-05:00 — #4
Thanks to both of you. I did not have it installed. I mistakenly thought it was a built in.
system — 2012-02-20T19:07:49-05:00 — #5
It's why when writing for others I don't use that function... you can't rely on it being present. Serves no real purpose anyways since getimagesize can return the 'type' just as good, anything user upload you should be running through a gd resample/resize anyways (forcing it to a image format), and nobody bothers putting anything useful in for exif data anyways -- and 99% of the time it just having what camera model it was taken with or a bunch of blank fields.
shinve — 2012-02-20T22:44:51-05:00 — #6
I was going to try it out over getimagesize because I am just using it confirm mime-types, and it is supposed to be faster for that, according to the php manual. But I probably won't be using it regardless because of it relying on an extension and there being a built in alternative.
logic_earth — 2012-02-20T22:49:16-05:00 — #7
function imagetype ( $image )
if ( function_exists( 'exif_imagetype' ) )
return exif_imagetype( $image);
$r = getimagesize( $image );
Thats how you do it.
shinve — 2012-02-21T16:45:33-05:00 — #8
Very nice, thank you.
system — 2014-10-07T21:59:07-04:00 — #9
This topic is now closed. New replies are no longer allowed.