Working with File Fields


File fields allow your visitors to attach computer files from their local machines to the form submission. This way, your visitors can upload things like image files, sounds, and text documents to the Web server. As you can see in Figure 68.3, a file field has two parts: the field itself and a Browse button.

Listing 68.3. View Source for Figure 68.3.
 <form>   <input type="file" name="imageFile" size="50" maxlength="70"> </form> 

Figure 68.3. Use file fields when you want to allow your visitors to upload files from their local machines to the Web server.


Once again, the name attribute identifies the file field. The size attribute gives the length of the field in characters, not pixels, while the maxlength attribute determines the maximum number of characters that the field will accept. In the example in Figure 68.3, with a size of 50 and a maximum length of 70, the visitor sees 50 characters in the field at a time, but the field stops accepting input after 70 characters.

FAQ

What happens to the uploaded file?

File fields can be tricky to handle on the server's side of things. Normally, forms of this type go directly into a database. The designer of the database needs to prepare a special column to accept file data instead of the usual text or numbers.


A valid path must appear inside the field for this widget to work correctly. That's why the file field includes a Browse button. When clicked, a dialog box opens, allowing the visitor to navigate to the exact file to upload. The browser then automatically fills in the correct path.



Web Design Garage
Web Design Garage
ISBN: 0131481991
EAN: 2147483647
Year: 2006
Pages: 202
Authors: Marc Campbell

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net