javascript - Preview an image before it is uploaded -
i want able preview file (image) before uploaded. preview action should executed in browser without using ajax upload image.
how can this?
please take @ sample js code below:
function readurl(input) { if (input.files && input.files[0]) { var reader = new filereader(); reader.onload = function (e) { $('#blah').attr('src', e.target.result); } reader.readasdataurl(input.files[0]); } } $("#imginp").change(function(){ readurl(this); });
and associated html:
<form id="form1" runat="server"> <input type='file' id="imginp" /> <img id="blah" src="#" alt="your image" /> </form>
also, can try sample here.
Comments
Post a Comment