Get multiple file information without uploading


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <input type="file" multiple id="files" name="files[]"/><br/>
  2.  
  3. <h3>Output</h3>
  4. <output id="list"></output>
  5.  
  6. <script>
  7. function handleFileSelect(evt) {
  8. var files = evt.target.files; // FileList object
  9. // files is a FileList of File objects. List some properties.
  10. var output = [];
  11. for (var i = 0, f; f = files[i]; i++) {
  12. output.push('<li><strong>', f.name, '</strong> (', f.type || 'n/a', ') - ',
  13. f.size, ' bytes, last modified: ',
  14. f.lastModifiedDate.toLocaleDateString(), '</li>');
  15. }
  16. document.getElementById('list').innerHTML = '<ul>' + output.join('') + '</ul>';
  17. }
  18.  
  19. document.getElementById('files').addEventListener('change', handleFileSelect, false);
  20.  
  21. </script>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.