javascript upload image input file code example
Example 1: File Upload Button and display file javascript
.custom-file-upload {
border: 1px solid #ccc;
display: inline-block;
padding: 6px 12px;
cursor: pointer;
}
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);
});