JSFiddle - React, Tailwind, and code Playground
by Oscar 11
HTML
<input type='file' multiple/>
<img id="myImg" src="#" alt="your image" />
JavaScript
$(function () {
$(":file").change(function () {
if (this.files && this.files[0]) {
var reader = new FileReader();
reader.onload = imageIsLoaded;
reader.readAsDataURL(this.files[0]);
}
});
});
function imageIsLoaded(e) {
$('#myImg').attr('src', e.target.result);
};