Return to Snippet

Revision: 49788
at July 29, 2011 22:05 by yingyi


Initial Code
<input type="file" multiple id="files" name="files[]"/><br/>

<h3>Output</h3>
<output id="list"></output>

<script>
  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.toLocaleDateString(), '</li>');
    }
    document.getElementById('list').innerHTML = '<ul>' + output.join('') + '</ul>';
  }
    
document.getElementById('files').addEventListener('change', handleFileSelect, false);

</script>

Initial URL

                                

Initial Description

                                

Initial Title
Get multiple file information without uploading

Initial Tags
javascript, html5

Initial Language
JavaScript