Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

png to base64 javascript

function toDataURL(url, callback) {
  var xhr = new XMLHttpRequest();
  xhr.onload = function() {
    var reader = new FileReader();
    reader.onloadend = function() {
      callback(reader.result);
    }
    reader.readAsDataURL(xhr.response);
  };
  xhr.open('GET', url);
  xhr.responseType = 'blob';
  xhr.send();
}

toDataURL('https://cdn.discordapp.com/attachments/571092147801948204/784586541146177606/6f32c864-985a-481d-8d8e-bd1f14ab9951.png', function(dataUrl) {
  console.log('RESULT:', dataUrl)
})
Comment

PREVIOUS NEXT
Code Example
Javascript :: for loop string array javascript 
Javascript :: regex js pattern tags 
Javascript :: calculate average javascript 
Javascript :: js create array with default value 
Javascript :: how to find last element in array in javascript 
Javascript :: create new angular project with specific version 
Javascript :: swap in javascript 
Javascript :: default Electron icon is used reason=application icon is not set 
Javascript :: send mail, nodemailer, nodemailer, mailer, nodemailer npm 
Javascript :: add toaster in angular 
Javascript :: how to add items in an array in js 
Javascript :: node.js ping 
Javascript :: get current file name javascript 
Javascript :: split array into chunks javascript 
Javascript :: how to make a random if else in js 
Javascript :: is jwt token expired 
Javascript :: how to send axios delete to the backend reactjs 
Javascript :: jquery wait for function to finish 
Javascript :: reset form input react 
Javascript :: react-active link 
Javascript :: how to append data to a field in mongoose model 
Javascript :: convert array to object 
Javascript :: send csrf token ajax laravel 
Javascript :: remove element from array by name javascript 
Javascript :: remove duplicate value from string 
Javascript :: fetching data with react 
Javascript :: codeblocks in html cdnjs 
Javascript :: primitive data types in javascript 
Javascript :: sum all values of an array 
Javascript :: cookie in javascript 
ADD CONTENT
Topic
Content
Source link
Name
2+8 =