I would like to upload multiple files on a single web page by having multiple <html:file> elements. The exact number of these are different depending on the user who is using the application. So I want to store this in an array (FormFile[]) in order to have N number of files uploaded. When I try to use <html:file/> tags in an iterate loop (with indexed="true") I get an error about requiring property attribute. There's isn't a good way of doing that so I just rendered the the HTML with scriplets. It looks something like:

<input type="file" name="workingfile"/>
<input type="file" name="notworkingfile[0]"/>
<input type="file" name="notworkingfile[1]"/>
<input type="file" name="notworkingfile[2]"/>

The form has getters and setters for workingfile (of type FormFile) and notworkingfile ( of type FormFile[] that is 3 elements). workingfile is assigned an instantied object however each element of notworkingfile[] is null after submit.

I then attempted to use commons-fileupload-1.1.1 in a struts action (struts 1.2.9) to read the uploaded data but it does not recognize that any files are being uploaded (including workingfile). I tried this code:

           List items = new ServletFileUpload(
                   new DiskFileItemFactory()).parseRequest(request);

items results in an empty collection (but not null). I've read that you can not use commons-fileupload in a struts action which may be why that doesn't work. Anyone know how to have variable number of file upload boxes? I know I could have properties for each file (file1,file2,file3 and so on) instead of array but I'd rather not implement it that way. Thanks!

Jeremiah

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

Reply via email to