After converting my canvas to a an image source using
canvas.toDataURL("image/png");
and passing it to a php file, how do I save it as a .png image on the server?
It's actually very simple, if you have allow-url-fopen enabled. PHP supports the data: URL scheme then, and automatically decodes base64 and urlencoding.
allow-url-fopen
data:
preg_match('#^data:[w/]+(;[w=]+)*,[w+/=%]+$#', $data=$_POST["dataU"]) and copy($data, "output.png");
But you could also just extract the part after the , and manually base64_decode() it.
,
base64_decode()
2.1m questions
2.1m answers
60 comments
57.0k users