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.
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. |