Skip to content

Instantly share code, notes, and snippets.

@gjp0609
Created January 2, 2020 06:59
Show Gist options
  • Save gjp0609/b908b788c51962e9b5b6b306ec10d679 to your computer and use it in GitHub Desktop.
Save gjp0609/b908b788c51962e9b5b6b306ec10d679 to your computer and use it in GitHub Desktop.
read text from file
<input id="file" type="file"/>
<script>
let input = document.getElementById("file");
input.addEventListener("change", function () {
if (this.files && this.files[0]) {
let myFile = this.files[0];
let reader = new FileReader();
reader.addEventListener('load', function (e) {
console.log(e.target.result);
});
reader.readAsBinaryString(myFile);
}
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment