Skip to content

Instantly share code, notes, and snippets.

@Guley
Created November 11, 2016 10:34
Show Gist options
  • Save Guley/0bf90235cb57c36d41bec3d24c27afa3 to your computer and use it in GitHub Desktop.
Save Guley/0bf90235cb57c36d41bec3d24c27afa3 to your computer and use it in GitHub Desktop.
<input type='file' name="image" onchange="preview(this);" multiple="multiple" />
<div id='previewImg'></div>
<script>
window.preview = function (input) {
if (input.files && input.files[0]) {
$(input.files).each(function () {
var reader = new FileReader();
reader.readAsDataURL(this);
reader.onload = function (e) {
$("#previewImg").append("<img class='thumb' src='" e.target.result "'>");
}
});
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment