码迷,mamicode.com
首页 > 其他好文 > 详细

Rails redmine upload

时间:2014-07-03 12:38:19      阅读:169      评论:0      收藏:0      [点我收藏+]

标签:des   java   os   javascript   cti   for   

controller

  def uploadss


    @attachment = Attachment.new(:file => request.raw_post)
    @attachment.author = User.current
    @attachment.filename = params[:filename].presence || Redmine::Utils.random_hex(16)
    @attachment.files_to_final_location
    puts @attachment.diskfile
    respond_to do |format|
      format.js
      format.api {
        if saved
          render :action => ‘upload‘, :status => :created
        else
          render_validation_errors(@attachment)
        end
      }
    end
  end

 

routes

  match ‘uploadss‘, :to => ‘foos#uploadss‘, :via => :post

 

erb

<span class="add_attachment">
<%= file_field_tag ‘attachments[dummy][file]‘,
      :id => nil,
      :class => ‘file_selector‘,
      :multiple => true,
      :size => 100,
      :onchange => ‘uploadBlob(this.files[0],"uploadss.js",1,"");‘,
      :data => {
        :max_file_size => Setting.attachment_max_size.to_i.kilobytes,
        :max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)),
        :max_concurrent_uploads => Redmine::Configuration[‘max_concurrent_ajax_uploads‘].to_i,
        :upload_path => "uploadss.js",
        :description_placeholder => l(:label_optional_description)
      } %>
(<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>)
</span>

<% content_for :header_tags do %>
  <%= javascript_include_tag ‘attachments‘ %>
    <%= javascript_include_tag ‘test‘, :plugin=>‘redmine_standard‘ %>
<% end %>

Rails redmine upload,布布扣,bubuko.com

Rails redmine upload

标签:des   java   os   javascript   cti   for   

原文地址:http://www.cnblogs.com/yuzhengdong/p/3821560.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!