Skip to content

Instantly share code, notes, and snippets.

@picpoint
Created January 15, 2020 17:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save picpoint/a735f05818bad9ad636dc53b266cc4d9 to your computer and use it in GitHub Desktop.
Save picpoint/a735f05818bad9ad636dc53b266cc4d9 to your computer and use it in GitHub Desktop.
read and output file on page
let inFile = document.querySelector('#inFile');
let outFile = document.querySelector('#outFile');
let fileReader = new FileReader();
fileReader.addEventListener('load', () => {
outFile.src = fileReader.result;
});
inFile.addEventListener('change', (e) => {
let file = e.target.files[0];
console.log(file);
fileReader.readAsDataURL(file);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment