image file input js code example
Example 1: input type file filter extensions
<input type="file" accept=".gif,.jpg,.jpeg,.png,.doc,.docx">
Example 2: how to display image before upload in jhtml
function display(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function(event) {
$('#myid').attr('src', event.target.result);
}
reader.readAsDataURL(input.files[0]);
}
}
$("#demo").change(function() {
display(this);
});