Created
May 11, 2017 12:17
-
-
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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