Possible Duplicate:
Sending images from Canvas elements using Ajax and PHP $_FILES
I created an application where users can edit in real time the content of a canvas tag. It then retrieves the contents of the tag like this:
var canvas = document.getElementById("canvas");
var imgca = canvas.toDataURL("image/png");
Now I am looking for a way to pass the contents of the imgca
variable to a PHP script that the user can then be sent by e-mail.
Does anyone has any idea?
You could try having a form with a hidden input element that posts to a php script and use your imgca to set the value of this hidden input element, so something likes this:
var canvas = document.getElementById("canvas");
var imgca = canvas.toDataURL("image/png");
document.getElementById("hiddenElement").value = imgca;
document.getElementById("myHiddenForm").submit();
with html:
<form id="myHiddenForm" action="somescript.php" method="post" style="display:none;">
<input type="hidden" id="hiddenElement" value="" />
</form>