JSFiddle - React, Tailwind, and code Playground

by Chuan Shao

HTML

<input type="file" id="input">

JavaScript

var inputElement = document.getElementById("input");
var reader = new FileReader();
reader.onloadend = function(){
  console.log(reader.result);
}
inputElement.addEventListener("change", handleFiles, false);
function handleFiles() {
  var fileSelected = this.files[0]; /* now you can work with the file list */
  reader.readAsBinaryString(fileSelected);
}