# Rails AJAX file upload without Flash and RJS, just a dream?

**URL:** <https://www.ruby-forum.com/t/rails-ajax-file-upload-without-flash-and-rjs-just-a-dream/185461>\
**Category:** Rails\
**Created:** [March 20, 2010, 4:51pm UTC](https://www.ruby-forum.com/t/rails-ajax-file-upload-without-flash-and-rjs-just-a-dream/185461 "2010-03-20T16:51:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lb2007](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/35a633/32.png) [@Lb2007](https://www.ruby-forum.com/u/Lb2007)\
**Post date:** [March 20, 2010, 4:51pm UTC](https://www.ruby-forum.com/t/rails-ajax-file-upload-without-flash-and-rjs-just-a-dream/185461/1 "2010-03-20T16:51:41Z")

</div>

As my app is continuing to grow a little older, I’ve come to the point  
where I want to allow a user to upload an avatar (with Paperclip)  
using AJAX. However, I’ve noticed just about the only way to get this  
done is to use the (imo) pretty dirty solutions with either Flash or  
the remote\_form\_for RJS stuff.

For instance  
[http://valums.com/wp-content/uploads/ajax-upload/demo-jquery.htm](http://valums.com/wp-content/uploads/ajax-upload/demo-jquery.htm)  
seems to offer a pretty neat solution on how to style the upload  
stuff, but from what I’ve read, it’s not possible to get this done  
properly due to the CSRF stuff.

So now I’m wondering; isn’t it possible to get AJAX uploads working  
using jQuery with the CSRF protection enabled, without using Flash or  
RJS?

Thanks so much in advance!

---

<div class="post-metadata">

**Author:** ![Lb2007](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/35a633/32.png) [@Lb2007](https://www.ruby-forum.com/u/Lb2007)\
**Post date:** [March 20, 2010, 11:24pm UTC](https://www.ruby-forum.com/t/rails-ajax-file-upload-without-flash-and-rjs-just-a-dream/185461/2 "2010-03-20T23:24:29Z")

</div>

On 20 Mar 2010, at 16:50, Lb2007 wrote:

> So now I’m wondering; isn’t it possible to get AJAX uploads working  
> using jQuery with the CSRF protection enabled, without using Flash or  
> RJS?

Until all browsers implement the HTML5 File API, one of those methods  
will have to do. Until then, this is just a dream:

> **[Using files from web applications - Web APIs | MDN](https://developer.mozilla.org/en-US/docs/Web/API/File_API/Using_files_from_web_applications)**
>
> Using the File API, web content can ask the user to select local files and then read the contents of those files. This selection can be done by either using an HTML element or by drag and drop.

Best regards

Peter De Berdt
