samedi 28 mars 2015

canvas.toDataURL() Security Error The operation is insecure FireFox

I have a HTML canvas that loads an image from localhost (or image of folder difference vs folder contain file.html), places it onto the canvas and overlays some other information to product a final image. When I try to use canvas.toDataURL () to output the file, I receive the message "The operation is insecure.", obviously due to cross-domain restrictions. **



SecurityError: The operation is insecure. imageObj = canvas.toDataURL("image/jpeg").replace("image/jpeg", "image/octet-stream");



**


I hope you can solve my problem ...


< div id="image"> < img id="img" src="http://localhost/wsc2015/upload/uploads/Face_2.jpg"alt="image"> < /div>



$(document).ready(function(e) {
var canvas = document.getElementById("myPicture");
var ctx = canvas.getContext("2d");

$(".save").on('click',function(){
var imgTest = document.getElementById("img");
ctx.drawImage(imgTest,0,0,460,600);
var imageObj = new Image();
imageObj.crossOrigin = "anonymous";
imageObj = canvas.toDataURL("image/jpeg").replace("image/jpeg", "image/octet-stream");

});

});

Aucun commentaire:

Enregistrer un commentaire