Child pages
  • File Upload

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

...

A form must be create with a form field of type file, <INPUT type="file" name="upload">. The form used to upload the file must have its encoding type set to multipart/form-data, <FORM action="doUpload" enctype="multipart/form-data" method="post">. The standard procedure for adding these elements is by using the Struts 2 tag libraries as shown in the following example:

Example JSP form tags:{snippet:id=example-form|lang=xml|javadoc=true|url=org.apache.struts2.interceptor.FileUploadInterceptor}The fileUpload interceptor will use setter injection to insert the uploaded file and related data into your Action class. For a form field named upload you would provide the three setter methods shown in the following example:

...

The struts.multipart.validationRegex is used to define a RegEx to be used to validate if the incoming request is a multipart request. The request must use the POST method and match the RegEx, by default the RegEx is defined as follow:

...

Please read RFC1341 the Multipart section for more details, existing Struts Multipart parsers support only multipart/form-data content type. This option is available since Struts 2.3.11.

...