3

I'm using this Script http://valums.com/ajax-upload/ to get Ajax upload working with Ruby on Rails

but when i try uploading a file on my controller action I only get this:

Parameters: {"qqfile"=>"Foo.png"}
{"qqfile"=>"Foo.png", "action"=>"ul_file", "controller"=>"upload_files"}

but i cant use this as a file and do things as

thefile = params[:qqfile]

foo = thefile.original_filename.slice(thefile.original_filename.rindex("."), thefile.original_filename.length).downcase

what do i need to do to get this script working with Ruby on Rails?

Thanks.

///////// Updated

This is how the JS looks Like



$(document).ready(function(){
    var uploader = new qq.FileUploader({
        // pass the dom node (ex. $(selector)[0] for jQuery users)
        element: $('#file-uploader')[0],
        // path to server-side upload script
        action: '/NzzT/upload_files/ul_file'
    });

});


5
  • what does the code you are using to create the ajax upload in js look like and is it being called? you know the new AjaxUpload(...) call? Commented Mar 23, 2011 at 21:49
  • You can check my update on the question i added the Javascript Call Commented Mar 23, 2011 at 21:56
  • I strongly recommend you use this brand new js plugin: github.com/blueimp/jQuery-File-Upload I wrote the tutorial in the wiki. Quick and easy Commented Mar 23, 2011 at 21:56
  • I'll give it a try because i can't get that 'Ajax Upload' plugin working Commented Mar 25, 2011 at 16:17
  • @apneadiving: Checked out the setup wrt the plugin you had suggested , found set up instructions for PHP.. does it suport RoR..? . My case is exceptional in a way.. I am trying to use an old config of Rails 2.0.2 and Ruby 1.8.7.. I actually have even a question posted on this..asking for appropriate ajax upload plugin for this quest..... stackoverflow.com/questions/6118753/… Commented May 27, 2011 at 9:32

2 Answers 2

1

my solution posted in this comment

I write QqFile for easy uploader. With paperclip example

Sign up to request clarification or add additional context in comments.

Comments

1

Here's a good solution using CarrierWave:

https://github.com/jnicklas/carrierwave/wiki/How-to%3A-Upload-from-a-string-in-Rails-3 https://groups.google.com/forum/#!topic/carrierwave/KBn2WmrwRAs

The syntax looks like this and works like a charm:

file = CarrierwaveStringIO.new(params[:qqfile], request.raw_post)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.