Convert canvas to image and upload image to server

Since the file you send is base64 encoded, you will need to decode and save the result into a file at a temp directory. From there it is just a normal server side wordpress image manipulation and insertion of the relevant info into the DB, something that there are many examples for on this site.

You should probably return the URL of the generated image in the AJAX response, but that depends on what results you need to show