将html5画布输出保存到我的rails应用程序 [英] save html5 canvas output to my rails app
问题描述
我正在尝试将html5画布的内容保存到我的Rails应用程序中。我找到了
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.
我使用carrierwave来处理图像,但我没有上传图像,而是希望用户在画布上绘制图像。
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?
谢谢
推荐答案
只需将网址内容放在隐藏字段中。
simply place the content of url in an hidden field.
<input type="hidden" name="canvascontent" id="canvascontent" />
javascript中的
(带jquery):
in javascript (with jquery):
var url = canvas.toDataURL('image/png');
$("#canvascontent").val(url);
这篇关于将html5画布输出保存到我的rails应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!