关于多个文件上传

上传多个文件上传参阅了

http://the-stickman.com/web-development/javascript/upload-multiple-files-with-a-single-file-element/

http://www.flex888.com/2007/03/23/multiple-file-upload-with-ruby-on-rails-acts_as_attachment.html

http://www.flex888.com/2007/03/23/multiple-file-upload-with-ruby-on-rails-acts_as_attachment.html

其本上以最下面的为主,我主要用RMagick ,filecolumn,然后是上面连接中的 cool multiple file upload JavaScript 下面是是上面文章中的一段截取

First of all, go here to download the cool multiple file upload JavaScript so that you can have the dynamic file list built up for uploading, like this:

根据上面的提示下载好uplad javascript

放在自己的工程里,关于rmargick,filecolumn文件上传的搭配参考再建rmargick filecoumn一文,网上也比较多,

好了之后在view中加入

java 代码
  1.       
  2.        
  3.     
  4.  "my_file_element" type="file" name="file_1" >   
  5.      
  6.     
  7. #在controller中加入
  8.     i = 0
        while @params["file_"+i.to_s] != "" and i <=2
           p = Hash["entry"=>{"image"=>""}]
            p["entry"]["image] = params["file_"+i.to_s] if i != 0
           @entry = Entry.create!(p["entry"])
          i += 1
        end
    就可以了,就可以实件文件上传了
  9. 如果你要一表多字段的话只要修改上面的代码就可以了,然后在 entry中
  10.   file_column :image, :magick => {   
        :versions => { "thumb" => "50x50", "medium" => "640x480>" }  
      } 
       file_column :image1, :magick => {   
        :versions => { "thumb" => "50x50", "medium" => "640x480>" }  
      }
  11. 增加相应的字段就可以了

 

此文多半属于抄阅,记下以便学习,请参考上面连接

关于如何使用file column 请参考

http://wiki.rubyonrails.org/rails/pages/HowToUseFileColumn

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值