Send Canvas Image Data Via Html Form, And Load Data Into New Blank Canvas Page
I have an HTML button that captures the canvas image using toDataURL(). I want to pass the data to a form element, which will send via formmail. I can get all other variables passe
Solution 1:
When you use:
var imgData = theCanvas.toDataURL();
imgData
should be then a string containing something like this data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNby...
this format is suitable for transfering in an HTML form (as opposed to some binary data).
To use imgData
to put it back somewhere on the canvas, you can use this:
var img = newImage();
img.src = imgData;
var ctx = theCanvas.getContext('2d');
img.onload = function() {
ctx.drawImage(img, 0, 0);
img.style.display = 'none';
};
Post a Comment for "Send Canvas Image Data Via Html Form, And Load Data Into New Blank Canvas Page"