Created
March 22, 2020 04:46
-
-
Save monbang/7935ee57b436b925d7a2d01d480a0e9b to your computer and use it in GitHub Desktop.
Photo upload preview on form
This file contains hidden or 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[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 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