I am trying to save the content of a html5 canvas to my Rails app. I found the
var url = canvas.toDataURL('image/png');
but I cant figure out how get that into my post/form.
Im using carrierwave to handle images but instead of uploading an image I want the user to draw one on the canvas.
I was thinking of something like setting the input file of the form to this content but that does not seem to be the way it works
Or maybe I should not be using the carrier wave?
thanks
The accepted answer didn't cover the carrierwave portion so here it is as I have it working in my app:
In my profile_images_contoller.rb I added the following functions:
Then in my "create" action I passed convert_data_uri_to_upload(params[:profile_image]) to ProfileImage.new()
Source: http://www.davehulihan.com/uploading-data-uris-in-carrierwave/
simply place the content of url in an hidden field.
in javascript (with jquery):