JSFiddle - React, Tailwind, and code Playground
HTML
<div class="photo_add">
<input type="file"/>
<img/>
</div>
<div class="photo_add">
<input type="file"/>
<img/>
</div>
<div class="photo_add">
<input type="file"/>
<img/>
</div>
<div class="photo_add">
<input type="file"/>
<img/>
</div>
CSS
img {
width:100px;
height:100px;
}
JavaScript
$(document).ready(function () {
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('.photo_add').find('input').next('img').attr('src', e.target.result);
};
reader.readAsDataURL(input.files[0]);
}
}
$('.photo_add').find('input').change(function (input) {
readURL(this);
});
});