0
This code gets an image for input file
and "transforms" into characters
There is a way to reverse the situation, with the characters obtained in the console.log forming the image again (throwing the image in the div secondImageView
)?
Thank you and follow the code:
function PreviewImage() {
var oFReader = new FileReader();
oFReader.readAsDataURL(document.getElementById("uploadImage").files[0]);
oFReader.onload = function (oFREvent) {
document.getElementById("uploadPreview").src = oFREvent.target.result;
console.log(oFREvent.target.result);
document.getElementById("txtimg").value = oFREvent.target.result;
};
};
<html>
<body>
<img id="uploadPreview" style="width: 200px; height: 100px; border: 1px #000 solid" />
<input id="uploadImage" type="file" name="myPhoto" onchange="PreviewImage();" /> <br /> <br />
<input id="txtimg" name="name_txt" class="txtimg" style="width:46px;" type="text"> <br>
<img id="secondImageView" style="width: 200px; height: 100px; border: 1px #000 solid" />
</body>
</html>
Very obg @Dobrychtop, I’ll study the code, you’re absolutely right !!
– Sora