# Upload with iframe or ajax?

**URL:** <https://www.ruby-forum.com/t/upload-with-iframe-or-ajax/109708>\
**Category:** Rails\
**Created:** [July 18, 2007, 6:32am UTC](https://www.ruby-forum.com/t/upload-with-iframe-or-ajax/109708 "2007-07-18T06:32:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![chamnap](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/779978/32.png) [@chamnap](https://www.ruby-forum.com/u/chamnap)\
**Post date:** [July 18, 2007, 6:32am UTC](https://www.ruby-forum.com/t/upload-with-iframe-or-ajax/109708/1 "2007-07-18T06:32:39Z")

</div>

Hello,

I really wonder whether I should upload with ajax or with iframe. I  
don’t know which way it should be the best of uploading file to the  
server? Please, give me some ideas…

Thanks  
Chamnap

---

<div class="post-metadata">

**Author:** ![chamnap](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/779978/32.png) [@chamnap](https://www.ruby-forum.com/u/chamnap)\
**Post date:** [July 18, 2007, 8:44am UTC](https://www.ruby-forum.com/t/upload-with-iframe-or-ajax/109708/2 "2007-07-18T08:44:47Z")

</div>

Unfortunately it is not possible to upload files with AJAX, since you  
can’t read the file from the input[type=file] fields with javascript.  
If you go with the iframe method you should check out the  
responds\_to\_parent plugin, makes things a heck of a lot easier.

There is another alternative though, that’s pretty nice if you’re  
willing to endure some serious pain and frustration: you can upload  
files with flash. Digitarald ([digitarald.de](http://digitarald.de)) made a nice prepackaged  
thingy for mootools, but it does need some tweaking for the Rails  
backend (like the CGI/session\_id fix). I don’t know of any  
[script.aculo.us](http://script.aculo.us) alternatives unfortunately.

/Jonas

---

<div class="post-metadata">

**Author:** ![chamnap](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/779978/32.png) [@chamnap](https://www.ruby-forum.com/u/chamnap)\
**Post date:** [July 18, 2007, 9:12am UTC](https://www.ruby-forum.com/t/upload-with-iframe-or-ajax/109708/3 "2007-07-18T09:12:49Z")

</div>

On 18 Jul 2007, at 08:28, JN\_Coward wrote:

> [script.aculo.us](http://script.aculo.us) alternatives unfortunately.  
> SWFUpload is also a Flash based solution, search the list archives, I  
> mentioned it a few times.

[http://search.gmane.org/](http://search.gmane.org/)?  
query=SWFUpload&author=peter&group=gmane.comp.lang.ruby.rails&sort=relev  
ance&DEFAULTOP=and&xP=swfupload&xFILTERS=Gcomp.lang.ruby.rails-Apeter  
+de+berdt—A

Best regards

Peter De Berdt
