Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 381
  • Last Modified:

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

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
stracqan
Asked:
stracqan
  • 2
1 Solution
 
_agx_Commented:
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
 
_agx_Commented:
>> IsImageFile(pathToFile) function

ie   <cfif IsImageFile(form.nameOfYourFileField)>
          ... good image. do something ...
      </cfif>
0
 
stracqanAuthor Commented:
Thanks!!
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now