Welcome to WebmasterWorld Guest from 54.242.53.253

Forum Moderators: mack

Message Too Old, No Replies

Image upload form

     
4:18 pm on Jun 8, 2009 (gmt 0)

New User

5+ Year Member

joined:May 1, 2009
posts: 31
votes: 0


I need a form on my site to be able to upload an image email it along with the relevant info in the form and then delete the image (if possible). To be more specific a cold fusion form. I have no idea how to even begin this. Any help would be greatly appreciated.
5:31 pm on June 9, 2009 (gmt 0)

Senior Member

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Nov 28, 2004
posts:7999
votes: 0


I've never coded in CF, but the "general" process would be something like this.

You have an upload form that must be a post method with the enctype multipart/form-data. This is because when you post the data, the image is uploaded as an "attachment" to the input data, separated by a boundary.

<form method="post" action="yourscript.cfm" enctype="multipart/form-data">
<input type="file" name="photo" id="photo">
<input type="submit" name="submitButton" value="Upload">
</form>

The server side processor locates the multipart boundary, separates it from the rest of the posted data and stores it in a file. Sometimes this is a temporary location (PHP) that needs to be moved, sometimes you can determine the file name/location directly.

A side note, you have to be very cautious of the uploaded file here, insuring it's a valid file upload and not a virus/malware. In other languages, such as perl or PHP, you can use the ImageMagick interfaces to check that it's actually an image file. Checking against a filename extension is not sufficient. Of course, there must be other data cleansing procedures as well to avoid potential injection attacks.

You would then need scripting that connects to the mail server and sends the email with the file as an attachment. Again, in other languages there are modules and tools to make this a relatively easy process.

On success, your script would delete the uploaded file and return a response to the browser.

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members