PDA

View Full Version : File Attachment in a Form


DSN
06-07-2005, 06:39 PM
Hi there,

I have build a page but it isn't finished.
the only thing i want to add is the possibillity
to add a file to the form. How can i add something like
a "browse..." button? and how can i be sure that the attachment
is really sent to my e-mail adress using a CGI script?
(I use this one: http://members.chello.nl/cgi-bin/mailto/~j.schirk/thanks.htm?Digisoft.Nijmegen@chello.nl )
I have been trying a few things like this code:

<form action="http://members.chello.nl/cgi-bin/mailto/~j.schirk/thanks.htm?Digisoft.Nijmegen@chello.nl Method="post">
(A few other fields)
<input type="file" Value="Bladeren..." name="userfile">
</form>
But that one didn't send the file itself. it only sent something like:
File=C:\My documents\Design.zip
I want to receive the file itself.
Can anyone help me?
(i added the html/form file as a .txt file)

(Sorry if my english isn't to good, it isn't my language)

greetings,

DSN

nikkiH
06-08-2005, 02:29 AM
Hi,

That's a file upload script. You need something on the server to get it and the form encoding needs to be set properly.
Set the field to <input type="file" name="whatever"> to get the browse button and the user can choose a file.
Set the form encoding to multipart form data.
<form enctype="multipart/form-data">

Then the back end needs configured to handle the file.
You should seriously think about third part on that because people could be sending you viruses and whatnot. Scanning the file would be an excellent idea.
You can find a bunch of stuff with Google if you enter
file upload attachment mail script
in the search box. I found this right away. It might help you.
http://www.sitepoint.com/article/uploading-files-cgi-perl

Oh, and this is totally nothing to do with Javascript DOM. I'm new here, so I'm not sure if they move threads, but they might move this to a better spot.