Answers for "javascript blob to image"

0

javascript blob to image

// GET BLOB FROM XML REQUEST (JAVASCRIPT)
var xhr = new XMLHttpRequest();
xhr.open("GET", "http://localhost/image.jpg");
xhr.responseType = "blob";
xhr.onload = response;
xhr.send();
// MAKE A RESPONSE FUNCTION (JAVASCRIPT)
function response(e) {
   var urlCreator = window.URL || window.webkitURL;
   var imageUrl = urlCreator.createObjectURL(this.response);
   document.querySelector("#image").src = imageUrl;
}
// MAKE OUTPUT IMG (IN HTML)
<img id="image"/>
  // THIS IS OPEN SOURCE I DO NOT OWN THIS //
Posted by: Guest on April-12-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language