im using this below function to encode the image using html5 canvas that im getting from user (here im using local imagefile)
jsfunction
function imgToDataURL(img) {
var canvas = document.createElement('canvas');
canvas.width = img.naturalWidth;
canvas.height = img.naturalHeight;
var c = canvas.getContext('2d');
c.drawImage(img, 0, 0);
var dataURL = canvas.toDataURL("image/png");
return dataURL;
}
its giving localimage cannot be loaded how to overcome this problem & is there any other way to encode the image to base64