FileList
FileList
This page has been flagged with the following issues:
High-level issues:
W3C Working Draft
Summary
FileList is an object which represents an array of individually selected files from the underlying system.
Properties
| API Name | Summary |
|---|---|
| length | length returns the number of files in the FileList object. If there are no files, this attribute must return 0. |
Methods
| API Name | Summary |
|---|---|
| item | item returns the indexth File object in the FileList. If there is no indexth File object in the FileList, then this method must return null. |
Events
No events.
Examples
iterates over all the files selected by the user using an input element
JavaScript
// fileInput is an HTML input element: input type="file" id="myfileinput" multiple
var fileInput = document.getElementById("myfileinput");
// files is a FileList object (similar to NodeList)
var files = fileInput.files;
var file;
// loop trough files
for (var i = 0; i < files.length; i++) {
// get item
file = files.item(i);
//or
file = files[i];
alert(file.name);
}
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 Mozilla Developer Network
: Article
Portions of this content come from the Microsoft Developer Network: Windows Internet Explorer API reference Article
This tool helps to make and review comments inline.
How to Use
insert instructions, with images, here