是否可以有两个不同的文件选择transloadit形式的文件



所以,我有一个模型(在rails项目中),它有一个徽标和一个封面图像,我想用一个表单上传它们,这可能与transloadit有关吗?我在任何地方都找不到一个例子。。。

这是我的项目。我用了6次。我希望它能有所帮助。。

new.html.haml

- title t('.new_provider')
.spacer
.row
  .span12
    = render 'shared/flash_messages'
    %h1= yield :title
.row
  .span12
    = bootstrap_form_for @provider, validate: true, html: {edit: "false", id: "providerform", enctype:"multipart/form-data", class: 'form-horizontal' } do |f|
      = transloadit_jquerify :providerform, :wait => true, :modal=>false
      = f.error_messages
      = render 'form', f: f
      .form-actions
        = f.submit t('.create'), id: 'provider_submit', class: 'btn btn-large btn-primary', disable_with: t('helpers.disable_with')
= render 'providers/modal_phone_verification' 

_form.html.haml

  = f.text_area :business_description, :id =>"business_description", :rows => "4"
  .controls
    %p.help-block{style:"margin-bottom: 15px; margin-top: -20px;"}
      %small
        = t('business_description_placeholder') 
  .control-group
    = label_tag :business_photos, t('.business_photos'), class: 'control-label'
    .controls
      = render partial: 'file_upload', :locals => {f: f}
      %span#file-error.help-inline{style: "display:none;color: #b44337"}=t('.file_presence_error')  
  .control-group
    .controls
      %p.help-block{style:"margin-bottom: 0px; margin-top: -20px;"} 
        %small
          = t('image_info')  

_file_uplod.html.haml

= transloadit :image_resize
-6.times do |index|
  .fileupload.fileupload-new.pull-left{style: "padding-right: 5px;", "data-provides" => "fileupload" }
    .fileupload-new.thumbnail{:style => "width: 130px; height: 130px;"} 
      -if @provider.provider_images.present?
        - if @provider.provider_images["provider_image#{index+1}"].present?
          %img{:id=>"providerimage1", :src => @provider.provider_images["provider_image#{index+1}"][0]}/
    .fileupload-preview.fileupload-exists.thumbnail{:style => "width: 130px; height: 130px;"}
    %div
      %span.btn.btn-file
        %span.fileupload-new{:id => "selectbutton"}
          -if index == 0
            =t('select_profile_image')  
          -else
            =t('select_image')              
        %span.fileupload-exists
          -if index == 0
            =t('select_profile_image')  
          -else
            =t('select_image')      
        =file_field_tag "provider_image#{index+1}", accept: 'image/png,image/bmp,image/jpeg,image/tif,image/jpg', :onchange =>"validateImageFiles(this);", :data => {:max_file_size => 5.megabytes}

相关内容

  • 没有找到相关文章

最新更新