I have found some strange behavior when uploading multiple files through a web form using, multiple instances org.apache.struts.upload.FormFile . As you may, or may not know, under the hood
Struts uses a CommonsMultipartRequestHandler to process forms of type multipart/form-data, and this class is essentially a wrapper around the Commons File Upload classes that do the work. The Struts config has a property on the controller tag called "maxFileSize". All Struts documentation suggests that this is the maximum file size that can be uploaded, and when uploading one file the behavior is exactly as you would expect - MultipartRequestHandler.ATTRIBUTE_MAX_LENGTH_EXCEEDED gets set to true, etc, etc. The problem arises when uploading multiple files. The result is that the "maxFileSize" parameter ends up applying to the combined size of all the files. Given the documentation and the name of the property "maxFileSize", I would think it would be much more logical (and useful) if the max size applied to each individual file. Without going into too much detail, when you trace through the Struts and Commons File Upload code, ultimately the "maxFileSize" is compared to HttpServletRequest.getContentLength() to see if the upload is too big. Obviously this will take into account the combined file sizes, so I wouldn't call this a bug, but I don't think the behaviour makes sense. What are your thoughts?