I'm trying to encode an image (jpg) to base64 using IE9. I tried the following code:
var canvas = document.createElement("canvas"); canvas.width = document.getElementById('myImage').width; canvas.height = document.getElementById('myImage').height; var ctx = canvas.getContext("2d"); ctx.drawImage(document.getElementById('myImage'), 0, 0); var dataURL = canvas.toDataURL("image/png"); return dataURL.replace(/^data:image\/(png|jpg);base64,/, ""); I got the error : DOM Exception: SECURITY_ERR (18) when I call toDataURL method.
Any idea what I'm doing wrong here?
Thanks