JSFiddle - React, Tailwind, and code Playground
HTML
<html>
<head>
</head>
<body>
<div>
<input type="file" id="files" name="files[]" multiple />
<output id="list"></output>
</div>
</body>
</html>
JavaScript
function handleFileSelect(evt) {
var files = evt.target.files; // FileList object
// files is a FileList of File objects. List some properties.
var output = [];
for (var i = 0, f; f = files[i]; i++) {
output.push('<li><strong>', f.name, '</strong> (', f.type || 'n/a', ') - ', f.size,
' bytes, last modified: ', f.lastModifiedDate ? f.lastModifiedDate.toLocaleDateString() : 'n/a',
'</li>');
}
document.getElementById('list').innerHTML = '<ul>' + output.join('') + '</ul>';
}
window.onload = function() {
// Check for the various File API support.
if (window.File && window.FileReader && window.FileList && window.Blob) {
// Great success! All the File APIs are supported.
} else {
alert('The File APIs are not fully supported in this browser.');
}
document.getElementById('files').addEventListener('change', handleFileSelect, false);
};