File
File
This page has been flagged with the following issues:
High-level issues:
W3C Working Draft
Summary
The File object provides information about files stored on the user's computer, and access to their contents. These are generally retrieved from a FileList object returned when a user selects files using the input element, or from a drag-and-drop operation's DataTransfer object.
Properties
| API Name | Summary |
|---|---|
| lastModifiedDate | The last modified date of the file. On getting, if user agents can make this information available, this must return a new Date object initialized to the last modified date of the file. If the last modification date and time are not known, the attribute must return the current date and time as a Date object. |
| name | The name of the file; on getting, this must return the name of the file as a string. There are numerous file name variations on different systems; this is merely the name of the file, without path information. On getting, if user agents cannot make this information available, they must return the empty string. |
Methods
No methods.
Events
No events.
Examples
Using form input for selecting files
JavaScript
function handleFileSelect(evt) {
var files = evt.target.files; // FileList object
// files is a FileList of File objects. List some properties.
var output = [];
for (var i = 0, f; f = files[i]; i++) {
output.push(escape(f.name),
f.size, ' bytes, last modified: ',
f.lastModifiedDate ? f.lastModifiedDate.toLocaleDateString() : 'n/a');
}
document.getElementById('list').innerHTML = output.join();
}
document.getElementById('files').addEventListener('change', handleFileSelect, false);
Related specifications
| Specification | Status | Related Changes |
|---|---|---|
| W3C File API Specification | W3C Working Draft |
Compatibility
Desktop
| Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
|---|---|---|---|---|---|
| Basic Support | 22.0 | 15.0 | 10.0 | 12.1 |
6.0 |
Mobile
| Feature | Android | BlackBerry | Chrome for mobile | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Opera Mini | Safari Mobile |
|---|---|---|---|---|---|---|---|---|
| Basic Support | 3.0 | 10.0 | ? | ? | ? | ? | Unsupported | 6.0 |
This article contains content originally from external sources.
Portions of this content come from the Microsoft Developer Network: Windows Internet Explorer API reference Article
Portions of this content come from HTML5Rocks! article
This tool helps to make and review comments inline.
How to Use
insert instructions, with images, here