1//ajax;;;;;;;;;;
2save.click((e)=>{
3 var data = canvas.toDataURL('image/png');
4 $.post('save.php',{'img':data},function(e){
5 console.log(e);
6 })
7})
8//php
9<?php
10$data = $_POST['img'];
11$file = "data/file.png"; // where you want to upload, file path;;;;;
12$uri = substr($data,strpos($data, ",") + 1);
13file_put_contents($file, base64_decode($uri));
14echo $file;
15?>