views:

223

answers:

4

I know how to POST/GET text values with ajax,

but never know how to upload files with ajax.

Can someone just give a simple demo here?

+3  A: 

GMail is actually using Flash for uploading files now... You could try looking into something like SWFUpload.

Mun
I'm not familiar with flash.Isn't there a solution for doing this with ajax?
Shore
A: 

Ajax could certainly upload files by posting a HTML form with a input type="file" in it.

Some links to get you started:

http://www.webtoolkit.info/ajax-file-upload.html

http://www.ajaxf1.com/tutorial/ajax-file-upload-tutorial.html

Depending on the server/server side language you could probably send some kind of progress info to the client to render as a progress bar.

Matthew Lock
A: 

Check out this Ajax upload scripts, it has examples in Php and .Net. The basic idea behind the script is that you have to create an iFrame to handle this.

J.W.
A: 

The YUI uploader is a flash based uploader that is designed to be very easy to integrate into javascript, with minimal knowledge of flash.

If you want a progress bar, I believe a pure javascript solution would require a server side piece to send back the current completion percentage via ajax, which would add quite a bit of complexity compared to a flash solution.

Chi