DWQA QuestionsCategory: JqueryHow to preview Image in jquery?
kundan roy asked 5 years ago

<script src=”https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js”></script&gt;
<script type=”text/javascript”>
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function(e) {
$(‘#preview’).attr(‘src’, e.target.result);
}
reader.readAsDataURL(input.files[0]);
}
}
jQuery(“#imgInp”).change(function($) {
readURL(this);
});
</script>