Apologies, this question has been asked multiple times, but asking again due to the lack of a suitable answer. I need to save a canvas drawing as an image in a folder on my server. Can it be done without using AJAX? The toDataURL
method returns the image data as base64 encoded. I need to save it to a folder as an image file. Is it possible?
Asked
Active
Viewed 8,968 times
2

Rutwick Gangurde
- 4,772
- 11
- 53
- 87
1 Answers
3
Response here How To Save Canvas As An Image With canvas.toDataURL()?
or open a new window with data URL:
var data = canvas.toDataURL('image/png');
window.open(data);
You just need to right click it ...
-
Thanks for the answer! But we want to do this automatically, without user intervention! Anyways I found a way to do it! Yours is the only and the closest answer, hence accepted! – Rutwick Gangurde Dec 07 '12 at 19:35
-
1@RutwickGangurde I also want to achieve the same functionality. Would you let me know how you managed to save the image without user interaction? – Rajat Varlani May 05 '15 at 17:02
-
Actually we had to do it via user interaction. The best way to go about it is save the image on every interaction. Meaning, if you're implementing functions via button clicks, you can force to save the image on every button click. Get the base64 image data via `canvas.toDataURL` and send it to your server in an AJAX post. Though it is going to be heavy and might crash your app since the user can choose to play around with your app by constantly clicking and the image might be a large file. – Rutwick Gangurde May 06 '15 at 05:58