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

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=25963

Handling for mulitiple "file" input with same name

           Summary: Handling for mulitiple "file" input with same name
           Product: Struts
           Version: 1.1 Beta 2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: File Upload
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


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.

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

Reply via email to