Home > FAQs > How do we upload files

You can obtain the MultipartRequestWrapper from the ServletActionContext or by utilizing the fileUpload interceptor. The fileUpload interceptor is preferred.


See the file upload page for more examples and advanced configuration

Ask the ServletActionContext

The MultipartRequestWrapper provideds access methods such as getFiles, getFile, getContentType, hasErrors, getErrors, and so forth, so that you can process the file uploaded.

Utilize the fileUpload Interceptor

(star) _Preferred_

  • Ensure that {{fileUpload }} Interceptor is included in the Action's stack.
    • (info) The default stack already includes {{fileUpload }}.
  • Ensure that the HTML form sets the enctype and specifies on or more file type inputs.
  • Ensure that the Action provides one or more fileUpload mutator methods, with names that correspond to name of the file type input.
  • The Action may also provide the corresponding accessor methods.

Handling multiple files

When multiple files are uploaded by a form, the files are represented by an array.


The Action class can define file handling methods that accept an array.

The uploaded files can be handled by iterating through the appropriate array.

Extra Information




Commons FileUpload


javax.servlet.context.tempdir as defined by container


Approximately 2M

@see struts.properties
@see org.apache.struts2.dispatcher.FilterDispatcher#doFilter(SerlvetRequest, ServletRepsonse, FilterChain)
@see org.apache.struts2.dispatcher.DispatcherUtil#wrapRequest(HttpServletRequest, SerlvetContext)
@see org.apache.struts2.dispatcher.multipart.MultipartRequestWrapper
@see org.apache.struts2.interceptor.FileUploadInterceptor