Skip to main content
Inspiring
February 1, 2008
Question

Processing uploaded files

  • February 1, 2008
  • 1 reply
  • 773 views
I need to upload photos to a site, I want to make sure that they are only JPG files uploaded, plus restrict the size.

Is there anyway to check the filesize and type before uploading? Or can somebody upload a 20meg EXE file that would hog our bandwidth?

Also, how do I check the file extension to make sure it's JPG? When I look at it I get TMP, and if I save it I seem to have to specify an extension?

Thanks

Mark
This topic has been closed for replies.

1 reply

Participant
February 3, 2008
Hi ACS LLC,

Please use the following reference sites. You can check the size of the file once the file uploaded or during the time of upload also and then you have to set custom message to user regarding the size of the file.

Reference 1: Checks the file size once uploaded
http://www.bennadel.com/blog/670-Ask-Ben-Limit-File-Upload-Size-In-ColdFusion.htm

Reference 2: The check is performed before uploading the file
http://tutorial120.easycfm.com/

And to ensure the file type you need to use another attribute in CFFILE tag called accept = "image/jpg"

Akbarsait
Chennai ColdFusion UserGroup, India
http://akbarn.wordpress.com/
ACS LLCAuthor
Inspiring
February 3, 2008
Thanks.

The filesize check was very handy (I should have figured that out myself from the DOCs)

The only issue I have is with accept = .. problem is that if I only accept JPG's it appears to throw a CF error if anything but that is uploaded.. is there a way to pick this up so I can process the error appropriately?

Thanks

Mark