views:

5141

answers:

6

I dont want to use jQuery, but id like to AJAX a file upload. is that possible?

if so, where could i find information / tutorial on it?

THANKS!

+24  A: 

No, it isn't possible to do this with javascript.

In order to give the 'AJAX' feel, however, you can submit a form to a hidden iframe and output the script results to it, then process from there. Google ajax iframe upload and get started from there.

If you are using jQuery, there is also the Form plugin which will automatically create this iframe for you if your form has any file fields in it. I haven't used it to do this, but I've heard good things.

As pointed out in the comments, you can also use something like the very popular SWFUpload to accomplish the desired effect with Flash.

Paolo Bergantino
You can also use Flash.
Jonathan Sampson
ah, yes. Added that.
Paolo Bergantino
You can also use silverlight.
bendewey
Eeeeh, you COULD....
Paolo Bergantino
very nicely put, I'll be quoting that in a report :)
Peter Perháč
A: 

Haven't used it personally, but Ajax Uploader is a component I recently came across which says it can do file uploads inside an UpdatePanel (assuming you're using ASP.NET).

Mun
+1  A: 

Here's a bit of detail about how gmail does it, using an iframe:

http://www.sajithmr.com/upload-files-like-gmail/

Chad Birch
+2  A: 

i use swfupload for multiple ajax-like uploads (its javascript/flash based)

Luis Melgratti
im down, im just kinda a stickler on re-inventing the wheel and doing it myself, at least the first time. i know its dumb, but im just the type of person that needs to do that;)
johnnietheblack
It's not dumb! actually it's great. The only way to learn. And the funny part its to learn. ;)
Luis Melgratti
+1  A: 

Strictly speaking there are possibilities to do real AJAX file uploads, but this is only possible in Firefox 3+, Safari 4 and Chrome 2. In all other browsers you must use a workaround like the iframe technique or a Flash based uploader.

Ionuț G. Stan
+1  A: 

Assuming you are using Java, DWR version 3.0 (currently in RC1) has support for binary file upload/download, which makes the problem trivially easy. I have not had a chance to try this out yet but we use DWR extensively with total success; it is a great Ajax toolkit.

http://directwebremoting.org/blog/joe/2008/12/16/dwr_version_3_0_release_candidate_1.html

Pete