Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Detecting whether a file in a server is an image file

Status
Not open for further replies.

jasonwcm

Programmer
Jan 28, 2004
12
MY
As titled, I wonder if anyone has tried to detect whether a file (which is residing in the server) is an image file. I've sort of downloaded file attachments in my inbox using CFPOP tag and now I would like to know which of these attachments are images.

Any help is greatly appreciated.

Cheers,

Jason
 
i don't know if you can actually 'detect' whether or not it truly is an image, but you can check the file extension to see if its .jpg or .gif (or any other known image extension)
Code:
<cfset ImageName = "image.jpg">
<cfset ImageTypes = ".jpg,.gif,.png">

<cfif ImageTypes CONTAINS Right(ImageName,4)>
FILE IS AN IMAGE
<cfelse>
FILE IS NOT AN IMAGE
</cfif>


=========================================
I have not failed. I've just found 10,000 ways that won't work.
Thomas A. Edison
 
Thanks..

I thought of that too.. But one could deliberately rename the extension to a valid image extension.

Any other thoughts?
 
nope, CF doesn't have any image manipulation tags/functions that i know of.

maybe you can with Java, but i can't help you there.


=========================================
I have not failed. I've just found 10,000 ways that won't work.
Thomas A. Edison
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top