Monday, February 6, 2012 8:25

Upload files by using Struts2

Tagged with:
Posted by on Monday, December 29, 2008, 15:23
This news item was posted in Web MVC category and has 0 Comments so far.

The Struts 2 framework provides built-in support for processing file uploads that conform to RFC 1867, “Form-based File Upload in HTML”. When correctly configured the framework will pass uploaded file(s) into your Action class. Support for individual and multiple file uploads are provided. When a file is uploaded it will typically be stored in a temporary directory. Uploaded files should be processed or moved by your Action class to ensure the data is not lost. Be aware that servers may have a security policy in place that prohibits you from writing to directories other than the temporary directory and the directories that belong to your web application.

Dependencies

The Struts 2 framework leverages add-on libraries to handle the parsing of uploaded files. These libraries are not included in the Struts distribution, you must add them into your project. The libraries needed are:

Library URL Struts 2.0.x Struts 2.1.x
Commons-FileUpload http://commons.apache.org/fileupload/ 1.1.1 1.2.1
Commons-IO http://commons.apache.org/io/ 1.0 1.3.2

References:

http://www.struts2.org/ajax-file-upload-in-struts2-using-ajax-file-upload-plugin/

http://www.javaeye.com/problems/1818

Leave a Reply

You can leave a response, or trackback from your own site.