Skip to content

Instantly share code, notes, and snippets.

@ishanray
Created March 20, 2018 21:28
Show Gist options
  • Save ishanray/fe77a45081a05f76966a3455ce366153 to your computer and use it in GitHub Desktop.
Save ishanray/fe77a45081a05f76966a3455ce366153 to your computer and use it in GitHub Desktop.
preview uploaded images
<form id="form1" runat="server">
<input type='file' id="imgInp" multiple='true' />
<div id="preview"></div>
</form>
function readURL(input) {
if (input.files && input.files.length) {
[...input.files].map(file=>{
var reader = new FileReader();
reader.onload = function (e) {
$('#preview').append($('<img/>').attr('src', e.target.result));
}
reader.readAsDataURL(file);
})
}
}
$("#imgInp").change(function(){
readURL(this);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment