Skip to content

Instantly share code, notes, and snippets.

@jparbros
Created August 16, 2012 15:41
Show Gist options
  • Select an option

  • Save jparbros/3371170 to your computer and use it in GitHub Desktop.

Select an option

Save jparbros/3371170 to your computer and use it in GitHub Desktop.
file_reader.js
function handleFileSelect(evt) {
var files = evt.target.files; // FileList object
window.fileContent = evt.target.result;
// files is a FileList of File objects. List some properties.
var output = [];
var contents = e.target.result;
for (var i = 0, f; f = files[i]; i++) {
output.push('<li><strong>', escape(f.name), '</strong> (', f.type || 'n/a', ') - ',
f.size, ' bytes, last modified: ',
f.lastModifiedDate.toLocaleDateString(), '</li>');
}
document.getElementById('test').innerHTML = '<ul>' + output.join('') + '</ul>';
}
document.getElementById('bulk_products_facets_csv').addEventListener('change', handleFileSelect, false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment