Skip to content

Instantly share code, notes, and snippets.

@Quinten
Created May 11, 2017 12:17
Show Gist options
  • Save Quinten/8a82899c110708e8faab57039db45acf to your computer and use it in GitHub Desktop.
Save Quinten/8a82899c110708e8faab57039db45acf to your computer and use it in GitHub Desktop.
Create an upload button and process file as json object (locally in the browser)
var uploadButton = $('<input type="file">');
uploadButton.change(function() {
var reader = new FileReader();
reader.onload = function (e) {
var target = e.target;
var data = JSON.parse(target.result);
console.log(data);
}
reader.readAsText(uploadButton[0].files[0]);
});
$('body').append(uploadButton);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment