Skip to content

Instantly share code, notes, and snippets.

@nikolaifedorov
Created December 21, 2013 22:58
Show Gist options
  • Save nikolaifedorov/8076316 to your computer and use it in GitHub Desktop.
Save nikolaifedorov/8076316 to your computer and use it in GitHub Desktop.
This example iterates over all the files selected by the user using an input element
// https://developer.mozilla.org/en-US/docs/Web/API/FileList
// 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);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment