DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=29807>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=29807

Support file uploads with the same parameter name

           Summary: Support file uploads with the same parameter name
           Product: Struts
           Version: 1.1 Final
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Enhancement
          Priority: Other
         Component: File Upload
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


It will be helpful (and also consistant with regular parameters) to support
putting uploaded files in a FormFile array when the HTML input parameter names
are the same for several file uploads.
I propose the following change to the addFileParameter() method in class
org.apache.struts.upload.CommonsMultipartRequestHandler:

    protected void addFileParameter(FileItem item) {
        FormFile formFile = new CommonsFormFile(item);
        
        Object o = elementsFile.get(item.getFieldName());
        if(o==null) {
            elementsFile.put(item.getFieldName(), formFile);
            elementsAll.put(item.getFieldName(), formFile);
        }
        else {
            FormFile[] files;
            if(o instanceof FormFile) {
                files = new FormFile[2];
                files[0] = (FormFile)o;
                files[1] = formFile;
            }
            else {
                FormFile[] oldFiles = (FormFile[])o;
                files = new FormFile[oldFiles.length+1];
                System.arraycopy(oldFiles, 0, files, 0, oldFiles.length);
                files[files.length-1] = formFile;
            }
            elementsFile.put(item.getFieldName(), files);
            elementsAll.put(item.getFieldName(), files);
        }
    }

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to