Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.ruby > #6452

Rails, using Andrew Valum's uploader

From Bigos <ruby.object@some.server.con>
Newsgroups comp.lang.ruby
Subject Rails, using Andrew Valum's uploader
Date 2012-02-11 13:15 +0000
Organization Aioe.org NNTP Server
Message-ID <jh5plq$s0d$1@speranza.aioe.org> (permalink)

Show all headers | View raw


Hi,

I am trying to create multiple file upload using Andrew Valum's uploader 
http://valums.com/ajax-upload/  .

When I try to upload example files I get following output:
background1.jpg 22.2kB Successfully Uploaded!
birdie.jpg 0.1MB       Failed
black.gif 1.5kB        Failed

Most of the time all files seem to be uploaded correctly despite  having 
error messages.

I can't understand what I am doing wrong here.



Relevant code in application.html.erb

<script>
function createUploader(){
     var uploader = new qq.FileUploader({
         allowedExtensions: [],
         element: document.getElementById('file-uploader-demo1'),
         action: '/wedding_photos/multiupload',

         onComplete: function(id, fileName, responseJSON){
           if (responseJSON.success) {
             $$('.qq-upload-failed-text').first().update(' Successfully 
Uploaded!');
           }
           else
           {
             $$('.qq-upload-failed-text').first().update(' Hmm .. upload 
failed');
           }
         }
     });
}
// in your app create uploader as soon as the DOM is ready
// don't wait for the window to load
window.onload = createUploader;
    </script>




And this is method definition in the relevant controller
  def multiupload
     logger.info "\n\n\n I'm in multiupload\n\n\n"

     @filename = params['qqfile']

     newf = File.open('/tmp/nextAttempt_' + @filename, "wb")
     str =  request.body.read
      newf.write(str)
     newf.close

     render :text => '{success:true}'
   end

--------the end----------the end---------

Back to comp.lang.ruby | Previous | Next | Find similar


Thread

Rails, using Andrew Valum's uploader Bigos <ruby.object@some.server.con> - 2012-02-11 13:15 +0000

csiph-web