Created
September 17, 2020 11:43
-
-
Save rakeshsoni18/ac763d47515a645e52e200114ff98b1e to your computer and use it in GitHub Desktop.
Image Preview Jquery
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
<img src="{{ asset('default-image-thumbnail.jpg') }}" alt="product-image" id="imageThumbnail" width="100%" height="170"> | |
// PRODUCT IMAGE PREVIEW | |
$('#product_img').on('change', function () { | |
var file = $(this).get(0).files; | |
var reader = new FileReader(); | |
reader.readAsDataURL(file[0]); | |
reader.addEventListener('load', function (e) { | |
var image = e.target.result; | |
$('#imageThumbnail').attr('src', image); | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment