This blog post accurately describes how to save canvases to the server using AJAX requests, I think this should be suitable for you.
var canvasData = testCanvas.toDataURL("image/png"); JavaScript. Base64 , : data:image/png;base64,fooooooooooobaaaaaaaaaaar==.
, AJAX HTML:
var ajax = new XMLHttpRequest();
ajax.open("POST",'testSave.php',false);
ajax.setRequestHeader('Content-Type', 'application/upload');
ajax.send(canvasData);
PHP script HTTP_RAW_POST_DATA $GLOBALS, , .
$filteredData=substr($GLOBALS['HTTP_RAW_POST_DATA'], strpos($GLOBALS['HTTP_RAW_POST_DATA'], ",")+1);
$decodedData=base64_decode($filteredData);
$fp = fopen( 'test.png', 'wb' );
fwrite( $fp, $decodedData);
fclose( $fp );
, test.png - , . data:image/png;base64, , base64_decode(). ($decodedData) .