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 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); });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <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