Convert Canvas element to image and save to database

I want to save the image in my server side database. After the user draws with the canvas and presses the button Submit, the Canvas element must be converted to an image format , and then I want to save this image in my database for future use. I can use this image to check the user the next time he visits my site.

Can someone help me figure it out? My server code is written in Java Servlets

+5
source share
1 answer

Use Canvas.toDataURL()that will return a base64 encoded string with PNG. Then you can save it as plain text or decode and save as a file. To return it to the canvas, you simply pass this line as the source forCanvas.draw(source, 0, 0) method

The script for you: http://jsfiddle.net/9a7Xd/

+7
source

All Articles