HTML and CSS Reference
In-Depth Information
like a regular text field, transmitting its value (that is, the file's path-
name) to the server instead of the contents of the file itself.
All of this is easier than it may sound. For example, here is an HTML
form that collects a person's name and favorite file:
<form enctype="multipart/form-data" method=post
action="cgi-bin/save_file">
Your name: <input type=text size=20 name=the_name>
<p>
Your favorite file: <input type=file size=20 name=fav_file>
</form>
The data transmitted from the browser to the server for this example
form has two parts. The first contains the value for the name field, and
the second contains the name and contents of the specified file:
-----------------------------6099238414674
Content-Disposition: form-data; name="the_name"
One line of text field contents
-----------------------------6099238414674
Content-Disposition: form-data; name="fav_file"; filename="abc"
First line of file
...
Last line of file
-----------------------------6099238414674--
The browsers don't check that the user has specified a valid file. If no
file is specified, the filename portion of the Content-Disposition head-
er is empty. If the file doesn't exist, its name appears in the filename
subheader, but there is no Content-Type header or subsequent lines of
file content. Valid files may contain nonprintable or binary data; there
is no way to restrict user-selectable file types. In light of these poten-
 
Search WWH ::




Custom Search