Answers for "Convert local url to base64 in javascript"

2

Convert local url to base64 in javascript

var xhr = new XMLHttpRequest();       
    xhr.open("GET", "/path/to/local/image/file", true); 
    xhr.responseType = "blob";
    xhr.onload = function (e) {
            console.log(this.response);
            var reader = new FileReader();
            reader.onload = function(event) {
               var res = event.target.result;
               console.log(res)
            }
            var file = this.response;
            reader.readAsDataURL(file)
    };
    xhr.send()
Posted by: Guest on August-04-2020

Code answers related to "Convert local url to base64 in javascript"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language