The string that you're getting can be used as the source attribute for an image, you just have to create a new Image
element to which you can assign it:
var image = new Image();
image.src = canvas.toDataURL("image/png", 1);
// append image to DOM
EDIT: Given the comments, you want to turn this into something that be stored in a database. You should POST
the result of toDataURL
to your server. Use your server-side technology's IO/image/graphics libraries to decode the base64-encoded part of the data string and write that out to a new file. You can now store that path in your database.
Alternative: just store that whole data string in your database. Then when you render your <img>
tag you can simply dump it into the src
attribute:
<img src="<< base-64 encoded data string>>" />