Solved

How do I validate an image upload server-side using ColdFusion?

Posted on 2011-02-15
3
376 Views
Last Modified: 2012-05-11
Hello,

I have an image upload on my page and I would like to validate that its actually an image server side after the form submits before I do anything with the image (i.e. actually upload it using <cffile).  I know ColdFusion has the <cfimage tag, but I don't know if that would be the right tag to use / how to use that tag to validate an uploaded image.

I know I could use RegEx to check the file extension, but that doesn't stop someone from saving a text file as .jpg and uploading it.  Therefore, I'm just looking for some good ol' server side validation for an image.

Thanks!!!!!!
0
Comment
Question by:stracqan
  • 2
3 Comments
 
LVL 52

Expert Comment

by:_agx_
ID: 34903031
You can use the IsImageFile(pathToFile) function to verify it's a recognized image.  


If upload security is your concern, these 2 are good reads
http://www.petefreitag.com/item/701.cfm
http://www.coldfusionjedi.com/index.cfm/2009/6/30/Are-you-aware-of-the-MIMEFile-Upload-Security-Issue
0
 
LVL 52

Accepted Solution

by:
_agx_ earned 400 total points
ID: 34903089
>> IsImageFile(pathToFile) function

ie   <cfif IsImageFile(form.nameOfYourFileField)>
          ... good image. do something ...
      </cfif>
0
 

Author Closing Comment

by:stracqan
ID: 34903146
Thanks!!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Hi, I will be creating today a basic tutorial on how we can create a Mail Custom Function and use it where ever we want. The main advantage about creating a custom function is that we can accommodate a range of arguments to pass to the Function and …
Hi. There are several upload tutorials using jquery and coldfusion. I found a very interesting one here Upload Your Files using Jquery & ColdFusion and Preview them (http://www.randhawaworld.com/) . I did keep the main js functions but made sever…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question