-2

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?

Community
  • 1
  • 1
Adrien
  • 37
  • 3
  • possible duplicate of [Sending images from Canvas elements using Ajax and PHP $\_FILES](http://stackoverflow.com/questions/5292689/sending-images-from-canvas-elements-using-ajax-and-php-files) and possible others like [clear Canvas and save Canvas](http://stackoverflow.com/questions/11693221/clear-canvas-and-save-canvas) – hakre Dec 15 '12 at 11:26

1 Answers1

0

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>
hakre
  • 193,403
  • 52
  • 435
  • 836
Jag
  • 1,744
  • 2
  • 11
  • 11