Click here to Skip to main content
15,894,291 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi

I have created a canvas on which a user can draw on i would like to know how would i be able to save the image drawn onto the canvas once the user clicks the save button?
Posted

1 solution

I am not sure why you have that scenario required but you can achieve it using below steps.

I am considering you have SVG available.

You can considering converting SVG to Binary (Image) and save that blob into database.

JavaScript
var html = d3.select("svg")
      .attr("version", 1.1)
      .attr("xmlns", "http://www.w3.org/2000/svg")
      .node().parentNode.innerHTML;


In above code you will get html as string of binary values which represents that Image.

Now you can convert this Binary String to Binary Array or you can store it as it is in database.

If you are achieving just to save Image on server, then I would suggest that generate an Image and save on server with unique GUID Name and save that information in database.

Thanks
Rushi
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900