1

I have my own implementation of text editor and would like to allow users to upload files by dragging and dropping it to the text editor. The editor uses iframe. I am using rails and remotipart to do async upload of image files. I tried using this plugin: http://chrismbarr.github.io/FileDrop/ but I can't figure out how to upload files using remotipart. I tried using AJAX but I am sure it is not the right way and moreover it does not work either:

$('#wysiwygtextfield').contents().find("html").fileDrop(
     {
      onFileRead:function(fileCollection){

           $.each(fileCollection, function(){
    // I should probably be uploading files to the server using remotipart here. 
    // the plugin iterates through the collection of files that are dropped 
          });
                                          },
         removeDataUriScheme: true
     }); 
   }) ;

Please comment if you need more code, the upload action or the html. I am using the following form to do async uploads of files using the remotipart gem and it works fine:

<%= form_for(:image, :remote => true , :url => 'upload',:multipart => true , 
             :html => { :id => 'upload_qimage'}) do |f| %>

 <%= f.file_field :image, :placeholder => 'No file chosen',:onchange => "$(this).parents('form').submit(); before_submit() ; ",class: "image_textbox"  %>

<% end %>
4

0 回答 0