davidpenuela davidpenuela - 6 months ago 25
Javascript Question

canvas to image and then upload to server

Im trying to save a canvas div and then upload it to the server but i cant manage to make it work.
so, this what i do:


  1. i create a canvas div where i will paint with paperjs

  2. i save that canvas div (dataToURL method)

  3. i try to upload it, but i doesn't work.



this is the web:
www.davidpenuela.com

I tested uploading an image to my server with jquery file uploader (test jquery uploader) and that script works, but i can make it work when saving from my canvas.

canvas2image is not working for me, it doesnt upload anything.

EDIT:
manage to make it work, I will post the way of doing it soon.
Thanks!

Answer

You can't get it it work because it is not a file upload. File uploads use encoded form data with a multipart/form-data content type. You client code is posting data that is not form encoded and has a canvas/upload content-type. You need to update your server code to make it aware of the 'canvas/upload' content type, or find a way to form encode the image before upload.

Comments