JSFiddle - React, Tailwind, and code Playground
HTML
<script>
function test() {
var file = document.getElementById('file').files[0];
var reader = new FileReader();
reader.onload = function(e) {
var image = document.createElement("img");
image.src = e.target.result;
document.body.appendChild(image);
}
reader.readAsDataURL(file);
}
</script>
<body>
<input type=file name=filename id=file>
<button type=button onclick='test()'>Display</button></br>
</body>