SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Zealot
    Join Date
    Nov 2011
    Posts
    196
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    exif_imagetype not working?

    I use the following code:

    PHP 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/functio...-imagetype.php

    Thanks.

  2. #2
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Its probably because you do not have the EXIF extension loaded in PHP.ini
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  3. #3
    SitePoint Mentor silver trophy
    Rubble's Avatar
    Join Date
    Dec 2005
    Location
    Cambridge, England
    Posts
    2,410
    Mentioned
    81 Post(s)
    Tagged
    3 Thread(s)
    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 Code:
    <?php phpinfo() ?>

  4. #4
    SitePoint Zealot
    Join Date
    Nov 2011
    Posts
    196
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks to both of you. I did not have it installed. I mistakenly thought it was a built in.

  5. #5
    Non-Member bronze trophy
    Join Date
    Nov 2009
    Location
    Keene, NH
    Posts
    3,760
    Mentioned
    23 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ShinVe View Post
    Thanks to both of you. I did not have it installed. I mistakenly thought it was a built in.
    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.

  6. #6
    SitePoint Zealot
    Join Date
    Nov 2011
    Posts
    196
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  7. #7
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    function imagetype $image )
    {
      if ( 
    function_exists'exif_imagetype' ) )
        return 
    exif_imagetype$image);

      
    $r getimagesize$image );
      return 
    $r[2];

    Thats how you do it.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  8. #8
    SitePoint Zealot
    Join Date
    Nov 2011
    Posts
    196
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by logic_earth View Post
    PHP Code:
    function imagetype $image )
    {
      if ( 
    function_exists'exif_imagetype' ) )
        return 
    exif_imagetype$image);

      
    $r getimagesize$image );
      return 
    $r[2];

    Thats how you do it.
    Very nice, thank you.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •