Created
April 13, 2023 06:35
-
-
Save hayskytech/f96a944d6db05c05b79d5715b87f3d53 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
<input type="file" id="imageUpload" onchange="previewImage()"> | |
<div id="imagePreview"></div> | |
<script type="text/javascript"> | |
function previewImage() { | |
var preview = document.getElementById('imagePreview'); | |
img = document.getElementById('imageUpload').files[0]; | |
var reader = new FileReader(); | |
if (img) { | |
reader.readAsDataURL(img); | |
} else { | |
// preview.innerHTML = ""; | |
} | |
reader.onloadend = function(){ | |
preview.innerHTML = reader.result; | |
} | |
} | |
</script> | |
<style type="text/css"> | |
#imagePreview{ | |
width: 400px; | |
height: 200px; | |
overflow: auto; | |
word-break: break-all; | |
border: 1px solid; | |
padding: 5px; | |
margin: 5px 0px; | |
font-family: Arial; | |
} | |
</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment