Created
March 20, 2018 21:28
-
-
Save ishanray/fe77a45081a05f76966a3455ce366153 to your computer and use it in GitHub Desktop.
preview uploaded images
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form id="form1" runat="server"> | |
<input type='file' id="imgInp" multiple='true' /> | |
<div id="preview"></div> | |
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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