16.7 File Upload Controls
<INPUT TYPE="FILE" ...> (No End Tag)
NAME (required), VALUE (ignored), SIZE, MAXLENGTH, ACCEPT, ONCHANGE, ONSELECT, ONFOCUS, ONBLUR (nonstandard)
This element results in a filename textfield next to a Browse button. Users can enter a path directly in the textfield or click on the button to bring up a file selection dialog that lets them interactively choose the path to a file. When the form is submitted, the contents of the file are transmitted as long as an ENCTYPE of multipart/form-data was specified in the initial FORM declaration. This element provides a convenient way to make user-support pages, where the user sends a description of the problem along with any associated data or configuration files.
Always specify ENCTYPE="multipart/form-data" in forms with file upload controls.
The NAME attribute identifies the textfield when the form is submitted.
For security reasons, this attribute is ignored. Only the end user can specify a filename.
SIZE and MAXLENGTH
The SIZE and MAXLENGTH attributes are used the same way as in textfields, specifying the number of visible and maximum allowable characters, respectively.
The ACCEPT attribute is intended to be a comma-separated list of MIME types used to restrict the available filenames. However, very few browsers support this attribute.
ONCHANGE, ONSELECT, ONFOCUS, and ONBLUR
<FORM ACTION="http://localhost:8088/SomeProgram" ENCTYPE="multipart/form-data"> Enter data file below:<BR> <INPUT TYPE="FILE" NAME="fileName"> </FORM>
Figure 1619 Initial look of a file upload control.
Figure 1620 A file chooser resulting from the user clicking on Browse in a file upload control.