jFileUploader - File uploading library for Java based web server
jFileUploader SourceForge.net Logo
Home | License | Download | Changelog | Author´s Home

Introduction:

jFileUploader is a pure java library that can be used to upload files to a webserver by using multipart/form-data encoding. The moethod processForm returns a Map.

Download the library and add it to your project. Then uploading a file becomes as easy as the two step process below.

Usage:

Step 1:
Copy the jFileUploader-1.0.jar to your lib directory.
Step 2:
Have this piece of code in your servlet.
import formprocessor.multipart.MultipartFormProcessor;
import formprocessor.exception.UploadException;
.
.
.
try {
     MultipartFormProcessor processor = new MulitpartFormProcessor();
     processor.processForm(request, new File("/my/upload/path"));
} catch(UploadException ue){
     out.println("Error Code : " + ue.getErrorCode());
     out.println("Error Message : " + ue.getErrorMessage());
}
For complete list of error codes and corresponding error messages refer UploadException source.

Return Value:

map.get(myElementName) then returns the value of the form element with name as myElementName. This is either a string or file depending upon the form element type. If the html form has multiple elements with the same name, e.g textboxes in a table, checkboxes etc, then map.get(name) will return an ArrayList with the corresponding component data type, i.e String for normal form elements and File for input type file.


Ready Troubleshooting:

  • Form encoding is of type multipart/form-data [specified by the `enctype` attribute of the form tag]
  • Every form element has a name. Values of form elements without a name will not be retrieved.

Bug reports/suggestions to Rohit Kumbhar [rohit DOT kumbhar AT gmail DOT com]

Thank you to Carl Smotricz for helping me to build this tool.

Enjoy Uploading!!!