Skip to main content
July 29, 2008
Answered

Detect image type

  • July 29, 2008
  • 5 replies
  • 1038 views
How do I detect the extension of an uploaded image? Would I use a cfimage function (I am on a cf8 server) or something else?
    This topic has been closed for replies.
    Correct answer Newsgroup_User
    cffile.serverfileext is easier and faster, but it just reads the
    uploaded extension - it does not guarantee the file is actually of that
    type. i.e. if i reame my .exe file to .gif and uploaded it, it will
    report .gif as extension.

    so yes, use the new cf8 image manipulation functions if you must verify
    the file is an image.


    Azadi Saryev
    Sabai-dee.com
    http://www.sabai-dee.com/

    5 replies

    July 29, 2008
    Hhahhaaa stop yelling at me! I did notice Azadi's post after I submitted my reply. I was also struggling with the cffile code because I was trying to execute it without uploading first but just by reading an image.

    I do have it working now though.

    SORRY!!!
    July 29, 2008
    None of these do what I'm looking for. Unless I'm missing something... I want to read an image, and output the extension. So for example, image.gif is uploaded to my server, I want to read in image.gif and be able to say that it has an extension of .gif. I read all the links provided and saw nothing about this. ImageInfo does the same thing as cfimage info.
    Inspiring
    July 29, 2008
    As Azadi Saryev has already told you cffile.serverfileext will be populated with what you want after the file is uploaded!
    Participating Frequently
    July 29, 2008
    Cold fusion8 is a nice software.
    For music visit http://mp3bravo.com
    July 29, 2008
    How would I do this with cf8?
    Inspiring
    July 29, 2008
    Hi,

    For getting the extension you need to use cffile.serverfileext as Azadi suggests.

    Meanwhile CF8 image functions like,

    IsImageFile To verify the image file is valid one.

    and

    IsImage

    etc.,

    Also the ImageInfo function returns a structure that contains information about the image.
    Newsgroup_UserCorrect answer
    Inspiring
    July 29, 2008
    cffile.serverfileext is easier and faster, but it just reads the
    uploaded extension - it does not guarantee the file is actually of that
    type. i.e. if i reame my .exe file to .gif and uploaded it, it will
    report .gif as extension.

    so yes, use the new cf8 image manipulation functions if you must verify
    the file is an image.


    Azadi Saryev
    Sabai-dee.com
    http://www.sabai-dee.com/