Search code examples
javascriptajaxjspfile-uploadforms

Asynchronous file upload (AJAX file upload) using jsp and javascript


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.


Solution

  • 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