Skip to content

Instantly share code, notes, and snippets.

@taeber
Created September 14, 2014 20:21
Show Gist options
  • Save taeber/90efbe971df22b490721 to your computer and use it in GitHub Desktop.
Save taeber/90efbe971df22b490721 to your computer and use it in GitHub Desktop.
Playing around with the File API
<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