Skip to content

Instantly share code, notes, and snippets.

@kelevro
Created September 28, 2016 13:34
Show Gist options
  • Select an option

  • Save kelevro/f78dd65390fba44e327f094907c517b4 to your computer and use it in GitHub Desktop.

Select an option

Save kelevro/f78dd65390fba44e327f094907c517b4 to your computer and use it in GitHub Desktop.
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#blah').attr('src', e.target.result);
}
reader.readAsDataURL(input.files[0]);
}
}
$("#imgInp").change(function(){
readURL(this);
});
<form id="form1" runat="server">
<input type='file' id="imgInp" />
<img id="blah" src="#" alt="your image" />
</form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment