Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML5 save canvas to file on server

i need to create a component using html5 canvas that given an image the user can paint on it and directly (via a kind of save button) upload it's customized version on the server.

Can i use html canvas for it ? Any suggestion ?

thx in advance

like image 973
GiulianoGro Avatar asked Sep 10 '10 11:09

GiulianoGro


1 Answers

You can get the image as data-url like this:

var dataUrl = document.getElementById('your-canvas').toDataURL();

You could then send this (very long string) to the server and save it to a file after decoding it (it is encoded in base64).

EDIT: Remember to submit this via POST, as suggested in the comments. GET has some length-limits in various browsers, so its likely to exceed those limits with such a huge amout of data.

like image 164
jwueller Avatar answered Oct 11 '22 12:10

jwueller