JSFiddle - React, Tailwind, and code Playground
by electronoob
HTML
<input type="file">
JavaScript
$(document).ready(function () {
$('[type=file]').change(function () {
if (!("files" in this)) {
alert("File reading not supported in this browser");
}
var file = this.files && this.files[0];
if (!file) {
return;
}
var fileReader = new FileReader();
fileReader.onload = function (e) {
var text = e.target.result;
//do something with text
console.log(text);
};
fileReader.readAsText(this.files[0]);
});
});