0
I have a form
where it has a input file
with preview
image before upload, trying to replace the input
for an image, but I’m not getting it.
<script>
// PREVIEW FOTO
function PreviewImage() {
var oFReader = new FileReader();
oFReader.readAsDataURL(document.getElementById("uploadImage").files[0]);
oFReader.onload = function (oFREvent) {
document.getElementById("uploadPreview").src = oFREvent.target.result;
};
};
</script>
HTML
<div class="image-upload"><label for="file-input">
<img src="https://i.pinimg.com/originals/54/38/19/543819d33dfcfe997f6c92171179e4cd.png" id="uploadPreview" style="width: 110px; height: 110px;" />
<input id="uploadImage" id="file-input" type="file" name="foto" onchange="PreviewImage();" />
CSS
<style type="text/css">
.image-upload > input
{
display: none;
}
</style>
Someone help me, I thank you in advance.
Thank you, it worked! A little question, there is no way to get the comic next to where the picture appeared then?
– user174392
Yes, remove CSS . image-upload > input { display: None;} and then the Select Image button will be next to the preview image.
– Marcel