You need to use AJAX to send the data to the server.
Something like this:
jQuery.ajax({ method: "POST", url: "save.php", data: { image: canvasToDataURLString } }) Then you will need some serverside code to save the image. Here is a PHP version modified from this answer: How to save a PNG image server-side, from a base64 data stringHow to save a PNG image server-side, from a base64 data string
$data = $_POST['image']; list($type, $data) = explode(';', $data); list(, $data) = explode(',', $data); $data = base64_decode($data); file_put_contents('image.png', $data); Now you should have an image called 'image.png' next to your php script.