File uploading using ajax


#1

Dear all,

I have a doubt, iam not getting the uploaded file when iam uploading
using ajax form like,

<% remote_form_for(:videos, :url => {:controller => :videos, :action
=> :add },
:html => { :multipart => true, :ajaxupload => true }) do |form| %>

File <%= form.file_field :uploaded_data %>

<%= submit_tag “uploadfile”%>

In controller when i call

params[:videos][:uploaded_data], iam getting a string like filename
<sample.gif>

but i was not able to reterive the uploadedfile and when i call methods
like

params[:videos][:uploaded_data].original_filename,
params[:videos][:uploaded_data].read iam getting errors.

So could anyone please suggest how to perform file uploading using ajax.

Thanks in advance

Regards,
Martin


#2

I don’t think it’s possible to upload files with AJAX, but there are
some workarounds with hidden iFrames. It’s not very elegant, but it
works.

See this, for instance:
http://kpumuk.info/ruby-on-rails/in-place-file-upload-with-ruby-on-rails/


#3

On 10 Jan 2009, at 07:37, dare ruby wrote:

So could anyone please suggest how to perform file uploading using
ajax.

http://www.google.com/search?client=safari&rls=en-us&q=rails+upload+ajax&ie=UTF-8&oe=UTF-8

Best regards

Peter De Berdt


#4

Use LiveQuery then you don’t need rjs and responds_to_parent

http://rails-revlog.blogspot.com/2009/02/ajax-sort-of-file-upload-using.html

Guy B.


#5

pena que parece que só funciona com jQuery…