Last active
October 8, 2020 07:46
-
-
Save Korveld/c4af2a15401d469e9fbd15fe16727564 to your computer and use it in GitHub Desktop.
Preview an image before it is uploaded on input file upload
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
| var readURL = function(input) { | |
| if (input.files && input.files[0]) { | |
| var reader = new FileReader() | |
| reader.onload = function(e) { | |
| $('.photo__img-wrap img').attr('src', e.target.result) | |
| } | |
| reader.readAsDataURL(input.files[0]) | |
| } | |
| } | |
| $('#photoInput').on('change', function() { | |
| readURL(this) | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment