Skip to content

Instantly share code, notes, and snippets.

Created February 24, 2019 22:15
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Bookmark to read local file
encodeURIComponent(`(function() {
function readLocalFile(e) {
const file =[0];
if (!file) {
alert('No file selected!')
const reader = new FileReader();
reader.onload = function(e) {
const contents =;
localStorage.setItem('mock', contents)
const element = document.createElement('input');
element.type = 'file';
element.addEventListener('change', readLocalFile, false);;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment