To display an image stored as a byte array in HTML and JavaScript, we can set the img element’s src
property.
For instance, we write
<img id="itemPreview" src="" />
to add the img element.
Then we write
document.getElementById("itemPreview").src =
"data:image/png;base64," + yourByteArrayAsBase64;
to select the img element with getElementById
.
And we set it to a base64 URL string with the image contents.