FileList

< apis‎ | file
Jump to: navigation, search

FileList

This article is Ready to Use.

W3C Working Draft

Summary

FileList is an object which represents an array of individually selected files from the underlying system.


Properties

No properties.

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

Attribution

This article contains content originally from external sources.

Portions of this content come from the Mozilla Developer Network cc-by-sa-small-wpd.svg: [FileList Article]

Portions of this content come from the Microsoft Developer Network: [fileList Object Article]