struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dave Newton <>
Subject Re: Multiple uploads / attachements
Date Tue, 03 May 2005 20:36:18 GMT
Abdullah Jibaly wrote:

>Does anyone have an example/pointers of uploading multiple files at one time?
I have several forms using DynaValidatorAtionForm that have two file 
uploads. There's not much interesting going on, though, the framework is 
doing the majority of the work for me.

A form bean, trimmed:

    <form-bean name="eventbean" 
      <form-property name="headerFile" 
type="org.apache.struts.upload.FormFile" />
      <form-property name="cssFile" 
type="org.apache.struts.upload.FormFile" />

The form in the JSP is declared to be a multipart.
Processing the upload. trimmed:

        FormFile cssFile = (FormFile) form_.get("cssFile");
        FormFile headerFile = (FormFile) form_.get("headerFile");
        Upload.uploadFormFile(cssFile, root);
        Upload.uploadFormFile(headerFile, root);

uploadFormFile, trimmed:

            InputStream instream = file_.getInputStream();
            byte[] contents = new byte[file_.getFileSize()];
            File outputFile = new File(root_ + "/" + file_.getFileName());
            FileOutputStream outstream = new FileOutputStream(outputFile);


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message