TYPE = FILE
FILE is used for doing file uploads in a form. File uploads are a relatively new
and still not well-standardized type of form input, but they show great promise once
the bugs are ironed out. File uploads allow you to send an entire file from your computer to the web server as part of your form input.
<FORM METHOD=POST ENCTYPE="multipart/form-data" ACTION="../cgi-bin/mycgi.pl">
File to upload: <INPUT TYPE=FILE NAME="upfile"><BR>
<INPUT TYPE=SUBMIT VALUE="Submit">
which gives us this form (please note that the CGI for this form is set to accept only very small files, so try sending something under 1K):
Configuring a form for file uploads requires setting two attributes in the
<FORM ...> tags in addition to using
(as in the example above). When the data is sent, the original file name (including the full path) of the file as it was on your computer is sent to the web server. The CGI, however, is free to save the file as anything it wants -- or to not save it at all.
For the time being, only use form-based file upload if you know that the users will
have Netscape (for example in an intranet or if the form is just for one person that you
know has Netscape) or MSIE 4.0 or later.
An often expressed wish with file uploads is to have a way of suggesting the file type being uploaded. Netscape, for example, when it gives you the file upload dialog box, inexplicably assumes you want to upload an HTML file. Unfortunately, there is no way to suggest a file type.