HTML and CSS Reference
In-Depth Information
The file input control allows you to browse for a file on your local network for the
purposes of uploading it to a website. Once you have selected the file, the file is dis-
played in some way, depending on the web browser, as shown in Figure 4-5 .
Figure 4-5. The appearance of the file input control in two different web browsers: Google
Chrome (top) shows the filename while Opera (bottom) displays the path to the file.
As mentioned earlier, for a form to successfully send binary data, such as is the
case when uploading a file, set the enctype attribute on the associated form to enc-
type="multipart/form-data" . This will properly format the form data so that
the file is available to a server-side script to process.
Note In PHP, there is a global variable called $_FILES that can be used to get ac-
cess to the uploaded file(s). You can find information on handling uploaded files in
PHP at .
By default only one file can be uploaded at a time; however, by adding the Boolean
multiple attribute to the file input control, multiple files can be selected for upload-
<input type="file" name="filedata" multiple />
Without this attribute, only one file at a time can be selected in the operating system's
file browser; however, with this attribute included, the Command key (Mac) or Control
key (Windows) can be held down to select multiple files. Again, the appearance of the
file input control will vary by browser, but it may look like Figure 4-6 .
Figure 4-6. The appearance of the file input control in Safari after multiple files have been selec-
Search WWH ::

Custom Search