You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Abdullah Jibaly <Ab...@aeroxchange.com> on 2005/05/03 22:16:55 UTC
Multiple uploads / attachements
Hi all,
Does anyone have an example/pointers of uploading multiple files at one time?
Thanks,
Abdullah
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Multiple uploads / attachements
Posted by Dave Newton <ne...@pingsite.com>.
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"
type="org.apache.struts.validator.DynaValidatorActionForm">
<form-property name="headerFile"
type="org.apache.struts.upload.FormFile" />
<form-property name="cssFile"
type="org.apache.struts.upload.FormFile" />
</form-bean>
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()];
instream.read(contents);
File outputFile = new File(root_ + "/" + file_.getFileName());
FileOutputStream outstream = new FileOutputStream(outputFile);
outstream.write(contents);
outstream.close();
Dave
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org