homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / WebmasterWorld / New To Web Development
Forum Library, Charter, Moderators: brotherhood of lan & mack

New To Web Development Forum

Image upload form

5+ Year Member

Msg#: 3928722 posted 4:18 pm on Jun 8, 2009 (gmt 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.



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

Msg#: 3928722 posted 5:31 pm on Jun 9, 2009 (gmt 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">

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.

Global Options:
 top home search open messages active posts  

Home / Forums Index / WebmasterWorld / New To Web Development
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved