JSFiddle - React, Tailwind, and code Playground
HTML
<form>
<img id="pre01">
<input type="file" name="file01" id="file01"><br/>
<hr size="1" width="100%"/>
<img id="pre02">
<input type="file" name="file02" id="file02">
</form>
JavaScript
$(function() {
$('input[type=file]').change(function() {
var input = $(this);
if(!!this.files && !!this.files[0]) {
var reader = new FileReader();
reader.onload = function(e) {
$('#pre' + input.prop('id').substr(4,2)).prop('src', e.target.result);
}
reader.readAsDataURL(this.files[0]);
}
});
});