Skip to content

Instantly share code, notes, and snippets.

@sebackend
Created November 10, 2019 19:49
Show Gist options
  • Save sebackend/7c355e7b1203a91be76769523fbf4a9e to your computer and use it in GitHub Desktop.
Save sebackend/7c355e7b1203a91be76769523fbf4a9e to your computer and use it in GitHub Desktop.
function previewImage(input, previewSelector) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function(e) {
$(previewSelector).attr('src', e.target.result);
}
reader.readAsDataURL(input.files[0]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment