# File uploading using ajax

**URL:** <https://www.ruby-forum.com/t/file-uploading-using-ajax/157379>\
**Category:** Rails\
**Created:** [January 10, 2009, 7:37am UTC](https://www.ruby-forum.com/t/file-uploading-using-ajax/157379 "2009-01-10T07:37:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![martin\_mercy2001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d2c977/32.png) [@martin\_mercy2001](https://www.ruby-forum.com/u/martin_mercy2001)\
**Post date:** [January 10, 2009, 7:37am UTC](https://www.ruby-forum.com/t/file-uploading-using-ajax/157379/1 "2009-01-10T07:37:03Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![martin\_mercy2001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d2c977/32.png) [@martin\_mercy2001](https://www.ruby-forum.com/u/martin_mercy2001)\
**Post date:** [January 10, 2009, 8:34am UTC](https://www.ruby-forum.com/t/file-uploading-using-ajax/157379/2 "2009-01-10T08:34:40Z")

</div>

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:

> **[In-place file upload with Ruby on Rails | Dmytro Shteflyuk's Home](https://kpumuk.info/ruby-on-rails/in-place-file-upload-with-ruby-on-rails/)**
>
> My friends often asked me how to upload file using AJAX, and usually they got answer "in no way". Correct answer, but what if I need to upload file without full page reloading? And, of course, I want to use RJS in this case. Here I'll explain what to...

---

<div class="post-metadata">

**Author:** ![martin\_mercy2001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d2c977/32.png) [@martin\_mercy2001](https://www.ruby-forum.com/u/martin_mercy2001)\
**Post date:** [January 10, 2009, 4:29pm UTC](https://www.ruby-forum.com/t/file-uploading-using-ajax/157379/3 "2009-01-10T16:29:15Z")

</div>

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](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

---

<div class="post-metadata">

**Author:** ![martin\_mercy2001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d2c977/32.png) [@martin\_mercy2001](https://www.ruby-forum.com/u/martin_mercy2001)\
**Post date:** [February 11, 2009, 10:06pm UTC](https://www.ruby-forum.com/t/file-uploading-using-ajax/157379/4 "2009-02-11T22:06:00Z")

</div>

Use LiveQuery then you don’t need rjs and responds\_to\_parent

> **[Ajax (sort of) File Upload using LiveQuery/jQuery](http://rails-revlog.blogspot.com/2009/02/ajax-sort-of-file-upload-using.html)**
>
> I was building an Ajax only app, the kind that loads a minimal start page and stuffs empty divs with GET responses that are generated by par...

Guy B.

---

<div class="post-metadata">

**Author:** ![martin\_mercy2001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d2c977/32.png) [@martin\_mercy2001](https://www.ruby-forum.com/u/martin_mercy2001)\
**Post date:** [February 12, 2009, 11:25am UTC](https://www.ruby-forum.com/t/file-uploading-using-ajax/157379/5 "2009-02-12T11:25:29Z")

</div>

pena que parece que sÃ³ funciona com jQuery…
