views:

3016

answers:

3

I am planning on having asynchronous file uploads. That is the file should be uploaded to a jsp or servlet and return something to the html/jsp page without reloading the original page. It should happen like an AJAX call. Is there any way to do it in AJAX or any other way to do it.

A: 

The latest dwr (http://directwebremoting.org/dwr/index.html) has ajax file uploads, complete with examples and nice stuff for users (like progress indicators and such).

It looks pretty nifty and dwr is fairly easy to use in general so this will be pretty good as well.

laura
anything similar for .net?
I don't know - only coded java for webservers so war
laura
A: 

I don't believe AJAX can handle file uploads but this can be achieved with libraries that leverage flash. Another advantage of the flash implementation is the ability to do multiple files at once (like gmail).

SWFUpload is a good start : http://www.swfupload.org/documentation

jQuery and some of the other libraries have plugins that leverage SWFUpload. On my last project we used SWFUpload and Java without a problem.

Also helpful and worth looking into is Apache's FileUpload : http://commons.apache.org/fileupload/index.html

Doomspork
It is indeed possible to do asynchronous file uploads without Flash; e.g. gmail.
DanM
If I'm not mistaken, Gmail uses flash as well.
Doomspork
+3  A: 

The two common approaches are to submit the form to an invisible iframe, or to use a Flash control such as YUI Uploader. You could also use Java instead of Flash, but this has a narrower install base.

(Shame about the layout table in the first example)

David Dorward