views:

7220

answers:

7

I would like to upload files just like google mail does. I would want to use jQuery and PHP to do it is there anyway of getting the progressbar etc.?

Here I added a video of how google does it. http://dl.getdropbox.com/u/5910/Jing/2009-04-02_1948.swf

No flash, no perl or cgi please..

I guess I can live without the progressbar now I am actually searching for information about jquery plugins or just what things I would need to look at

+4  A: 

The easiest would be to use SWFUpload, it's a small button written in Flash, with all the hooks to drive it in JS. Very easy to use and works well with PHP

but, if you really want it to be pure JS, you'll need some help from the server. specifically, you'll need to start the upload, and periodically query the server about how's it going. unfortunately, PHP upload handling doesn't get any notification until after the download finishes. you'd have to replace it with something else. there are a few pure JS uploaders that include sample Perl server code just because of that.

IOW: JS and PHP don't (fully) cut it. either add flash to the client, or a better upload handler at the server.

Javier
Yes. If you can go with Flash. This will save you days of work.
Aaron Qian
SWFUpload is excellent, only problem is that there is no way how to degrade it gracefully when flash is not available without writing the js handling yourself. What they call graceful degradation is just displaying warning box and hiding the upload button...
jhexp
+2  A: 

PHP doesn't support reporting of upload progress directly. So there is no way of reading the upload status back. However, there is a patch that might work. I haven't tried though.

Aaron Qian
example doesn't even seem to work :(
Thomaschaaf
PHP doesn't *easily* support upload progress. It is possible, but seriously not worth it.
Paolo Bergantino
+2  A: 

Uploadify is another swf (sorry) upload button that uses jquery. Same idea as what Javier mentioned.

NetHawk
+1  A: 

GMail uses Flash to upload the file in the background. SWFUpload is an open source project that foes something similar.

Julien
A: 

...gmail uses an iFrame that has style display:hidden; then when you upload on the form, it then sends the iFrame to the upload url. There is no flash involved at all. The only thing Google does with flash on Gmail is just making noises for chats. And you have to allow that in settings. They don't really use flash too much just because it is pretty bad as far as memory and cpu usage. Javascript can do anything flash can do (albiet with a lot more code in some cases) but Javascript, in 99% of cases is much faster, and better memory-wise.

B Squared
Are you running Linux? They don't serve the Flash uploader to Linux clients because of bugs in the Linux Flash player. SWFUpload, for example, has a known issue where it freezes browsers on Linux.
Brandon Bloom
+4  A: 

It is weird that people say that gmail doesn't use flash, when you can plainly see the swf file in the gmail interface. Try right clicking on "Attach a file". It is what allows the multiple uploads at once among other things.

Jake
+1 You are right, thanks!
Marco Demajo
A: 

SWFUpload is gud and compatible with all type of web applications

yasirmturk