Skip to content

Instantly share code, notes, and snippets.

@ishanray
Created March 20, 2018 21:28
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
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