JSFiddle - React, Tailwind, and code Playground
HTML
<input type="file" id="newJson" name="newJson" value="file" />
<div id="contents"></div>
JavaScript
if (window.File && window.FileReader && window.FileList && window.Blob) {
function handleFileSelect(evt) {
var file = evt.target.files[0],
reader = new FileReader(),
contents;
if( file ){
reader.onload = function(f){
contents = f.target.result;
console.log( contents );
document.getElementById('contents').innerHTML = contents;
};
reader.readAsText(file);
}
}
document.getElementById('newJson').addEventListener('change', handleFileSelect, false);
} else {
console.log( 'File API not supportes, sorry' )
}