What I am able to do right now is to get the content of a canvas and convert it to a png using img.src = toDataUrl().
What I would like to do now is to upload that img on a remote ser开发者_高级运维ver using PHP. Is there a way that this can be done?
Take a look at how it's done here (the second post). You need to have the cURL PHP extension installed on your web server.
Send the result of canvas.toDataURL()
var imageInfo = canvas.toDataURL(); /* sample: data:image/png;base64,iVBORw0KGgo..." */
Direct way to create the png file:
<?php
$image = fopen($imageInfo, 'r');
file_put_contents("fileName.png", $image);
fclose($image);
?>
精彩评论