How do I get a canvas to attach to paperclip so I can save it into my database?

时间:2015-10-30 23:06:55

标签: javascript ruby-on-rails html5 canvas paperclip

I have a little demo of this of my camera app:

https://shielded-plains-5586.herokuapp.com/

When you press "Drop', it creates a canvas after you take a picture with a webcam below it. My problem is that I don't know how to get the canvas into an image and have it save to my database through a form with paperclip on it. I'm really stumped. could anyone help?

1 个答案:

答案 0 :(得分:0)

使用canvas.toDataURL(),将返回图像数据URI。

将其发布到您需要编写文件的服务器并将路径保存在数据库中。

https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/getImageData