Created
December 21, 2013 22:58
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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