Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
This recipe will use the File interface to get the name, type, size, and last-modified date of a file selected by the page visitor through the standard file input element. Before showing how to get this information, the recipe will show how to validate that the FileList interface is available in the browser. To display the attributes of a file, as shown in Listing 14.1, perform the following steps:
1. | Create a blank HTML page with a file input element, and add the onchange event handler to be called when a file is selected. |
2. | Add the fileAttributes section to the HTML body where the recipe will display the file attributes. |
3. | Add the handleFile function, taking fileInput as the parameter. |