There have been quite a few threads on this topic.
If you search the archives you should be able to find some tips on how to do
it.
http://marc.theaimsgroup.com/?l=struts-user&w=2&r=1&s=multiple+file+upload&q
=b

-----Original Message-----
From: Darren Hartford [mailto:[EMAIL PROTECTED]
Sent: Thursday, 15 January 2004 05:15
To: [EMAIL PROTECTED]
Subject: FW: Multiple formfile uploads - howto?


Hey all,
With a simple JSP page with just one <strutshtml:file> tag I can easily load
a file into a FormFile object into my Form (with normal getter and setter),
and then use an Action to work with the Form.

But, when trying to make this simple JSP page display 1-N
<strutshtml:file...> tags to load up many files, the system breaks in
between the JSP page and the Form, never reaching the Action.  I have not
had success with FormFile[], HashMap, etc.

==JSP code==
<!-----for HashMap---->
<strutslogic:iterate id="ai" name="uploadform" property="mystuff">
    <TR>
        <TD>
            <CENTER><strutshtml:text name="ai"
property="key"/>filename</centeR>

        </TD>
        <TD>
            <strutshtml:file styleClass="fileInput" size="100" name="ai"
property="value" />
        </TD>
    </TR>
</strutslogic:iterate>
<!-----or for FormFile[]---->
<strutslogic:iterate id="ai" name="uploadform" property="mystuff">
        <TD>
            <CENTER><strutshtml:text name="ai" property="mystuff"/></centeR>

        </TD>
</strutslogic:iterate>


==Form code==
public class UploadForm extends BaseForm {

/*HashMap doesn't work*/
protected java.util.HashMap mystuff = new HashMap();
public HashMap getMystuff() {
  return mystuff;
}
public void setMystuff(HashMap mystuff) {
  this.mystuff = mystuff;
}

/*FormFile[] doesn't work*/
protected FormFile[] mystuff;
public FormFilegetMystuff() {
  return mystuff;
}
public void setMystuff(FormFilemystuff) {
  this.mystuff = mystuff;
}


==ERROR==
argument type mismatch

Has anyone been successful in uploading an unknown number of files at once
through Struts, or is Struts unable to handle this?

TIA!
-D

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



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

Reply via email to