[ https://issues.apache.org/struts/browse/STR-1915?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Joe Germuska closed STR-1915. ----------------------------- Resolution: Duplicate This appears to be a duplicate of STR-487 which has a patch with a test. > [upload] Handling mulitiple file input with same name > ----------------------------------------------------- > > Key: STR-1915 > URL: https://issues.apache.org/struts/browse/STR-1915 > Project: Struts 1 > Issue Type: Improvement > Components: Core > Affects Versions: 1.1 Final > Environment: Operating System: All > Platform: All > Reporter: Jackey Cheong > Assigned To: Martin Cooper > Priority: Minor > Attachments: fileArray.patch, objectArrayToScalar.patch > > > Hello, > I think We can have multiple "file" input elements with same name in the > form, > as well as other type of input element. > for example, > <input type="file" name="file1"/> > <input type="file" name="file1"/> > <input type="file" name="file1"/> > But, current "CommonsMultipartRequestHandler" class seems to be not able to > this case. > I think we need change this class code as following. > CommonsMultipartRequestHandler.addFileParameter() > =========== current ============= > FormFile formFile = new CommonsFormFile(item); > elementsFile.put(item.getFieldName(), formFile); > elementsAll.put(item.getFieldName(), formFile); > =========== my suggestion ============= > String name = item.getFieldName(); > FormFile formFile = new CommonsFormFile(item); > FormFile[] oldArray = (FormFile[]) elementsFile.get(name); > FormFile[] newArray; > if (oldArray != null) { > newArray = new FormFile[oldArray.length + 1]; > System.arraycopy(oldArray, 0, newArray, 0, oldArray.length); > newArray[oldArray.length] = formFile; > } else { > newArray = new FormFile[] { formFile }; > } > elementsFile.put(name, newArray); > elementsAll.put(name, newArray); > Best Regards. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.