How to use File API on input file type. There are several interfaces for accessing files from a ‘local’ filesystem.
if (window.File && window.FileList && window.FileReader && window.Blob) {
// File API is fully supported
}
// using the .get() method
var file = $(".inputFile").get(0).files;
// using the access notation
var file = $(".inputFile")[0].files;
// using the function
$(".inputFile").on("change", app.onFile);
app.onFile = function(event) {
var file = event.target.files[0];
}
name: File name
size: File size
type: File type
lastModified: File lastModified
lastModifiedDate: File lastModifiedDate
var file = $(".inputFile").get(0).files;
console.log(file.name);
console.log(file.size);
console.log(file.lastModified);
<input type="file" class="inputFile" multiple />
<input type="file" class="inputFile" accept="image/*" />
<input type="file" class="inputFile" accept=".txt" />