Created
February 9, 2022 06:21
-
-
Save pradeeprjth/07c036a2c7e39c0eb1efd832bf8fc762 to your computer and use it in GitHub Desktop.
This file contains 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) { | |
$('#imageResult') | |
.attr('src', e.target.result); | |
}; | |
reader.readAsDataURL(input.files[0]); | |
} | |
} | |
$(function() { | |
$('#upload').on('change', function() { | |
readURL(input); | |
}); | |
}); | |
/* ========================================== | |
SHOW UPLOADED IMAGE NAME | |
* ========================================== */ | |
var input = document.getElementById('upload'); | |
var infoArea = document.getElementById('upload-label'); | |
input.addEventListener('change', showFileName); | |
function showFileName(event) { | |
var input = event.srcElement; | |
var fileName = input.files[0].name; | |
infoArea.textContent = 'File name: ' + fileName; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment