How do I preview several different images from different inputs?
Here is an example of how I wanted it to be
HTML
<div class="col">
<input type="file" class="custom-file-input" name="arquivo" id="files" onchange="preview(this);">
<div class="preview-img">
<img id="preview_image" alt="" src="">
</div>
</div>
<div class="col">
<input type="file" class="custom-file-input" name="arquivo" id="files" onchange="preview(this);">
<div class="preview-img">
<img id="preview_image" alt="" src="">
</div>
</div>
<div class="col">
<input type="file" class="custom-file-input" name="arquivo" id="files" onchange="preview(this);">
<div class="preview-img">
<img id="preview_image" alt="" src="">
</div>
</div>
JavaScript
function preview(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#preview_image')
.attr('src', e.target.result)
.width(100)
.height(100)
};
reader.readAsDataURL(input.files[0]);
}
}