Created
September 14, 2014 20:21
-
-
Save taeber/90efbe971df22b490721 to your computer and use it in GitHub Desktop.
Playing around with the File API
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
<input type="file" id="input"> | |
<br /> | |
<pre id="output"></pre> | |
<script> | |
var output = document.getElementById("output"); | |
var input = document.getElementById("input"); | |
function handleFiles() { | |
var file = this.files[0]; | |
var reader = new FileReader(); | |
reader.addEventListener("loadend", function() { | |
output.innerHTML = reader.result; | |
}, false); | |
reader.readAsText(file); | |
} | |
input.addEventListener("change", handleFiles, false); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment