简体   繁体   English

是否可以使用Rails和Paperclip远程上传图像?

[英]Is it possible to remotely upload an image using Rails and Paperclip?

I would like to know whether it is possible to remotely submit an upload image form using Rails and the paperclip gem. 我想知道是否可以使用Rails和回形针gem远程提交上传图像表单。

Here is an example form 这是一个示例表格

 = semantic_form_for @material.images.build, :url => images_path(@article), :html => {:multipart => true, :class => "image-upload-form form-inline"}, :remote => true do |f|
     = f.input :file
     = f.input :credit
     = f.submit "Upload Image"

Here is the create action: 这是创建动作:

 def create
    #some code to handle create
    respond_to do |format|
      format.json
      format.js
      format.html {redirect_to @article}
    end
 end

I can get submit to work for html submit, but not yet for remote submission. 我可以让html提交工作,但是还不能进行远程提交。 So, I'm wondering - Is it possible to upload an image remotely in Rails? 所以,我想知道-是否可以在Rails中远程上传图像? I use Paperclip, but if it isn't possible for paperclip i'm also interested generally for rails image upload gems. 我使用回形针,但如果不能使用回形针,我通常也对Rails图像上传gem感兴趣。

尝试使用remotipart gem( https://github.com/leppert/remotipart

There is another gem for upload in Rails : carrierwave . Rails中还有另一个要上载的宝石: carrierwave I think it is able to do it . 我认为它能够做到。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM