I would like to know how I can convert to base64 an image that I have stored on my computer that has a url like this (folder / id / img.jpg)
So far I have tried this but it does not work for me, when I do the console.log and I see the data path in the console: it brings me and I give it click it goes all black without bringing any image
var c = document.createElement('canvas');
c.width = 200;
c.height = 200;
var ctx = c.getContext('2d');
var img = new Image();
img.src = url;
ctx.drawImage(img, 0, 0);
var imgData = ctx.getImageData(0, 0, 200, 200);
ctx.putImageData(imgData, 0, 0);
var file = c.toDataURL();
console.log( file );