commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Cooper <>
Subject Re: File Upload problem
Date Tue, 19 Jul 2005 16:24:22 GMT
On 7/18/05,
<> wrote:
> Hi experts
> In my application, I use commons-fileupload-1.0.jar for file upload.
> In the Jsp page,
> I use the <html:form action="EventDetailsForScheduler"
> enctype="multipart/form-data" method="POST">.
> and a file for field
> <html:file name="eventdetailsform" property="imageFile" size="40"/>
> In the Formbean class I have a property imageFile of Type FormFile to
> capture this value.
> I want the Action class to do the file uploading( I use the builtin
> ActionServlet only...No customized Servlet or anything..)
> In the execute Method,
> I use the following code
>                 DiskFileUpload fu = new DiskFileUpload();
>                 // If file size exceeds, a FileUploadException will be
> thrown
>                 fu.setSizeMax(1000000);
>                 List fileItems = fu.parseRequest(req);
>                 Iterator itr = fileItems.iterator();
> But the size() method of this Iterator returns zero file is
> sent for uploading..
> I tried printing the file name in the
> setImageFile() method of the bean.and is correctly printing.then why it is
> not retrived in the Action class?
> Cannot I handle the fileuploading inside the Action class?

Struts has file upload handling built in, so you don't need to do it
yourself. The problem you are seeing is happening because Struts has
already parsed the request and populated the form bean for you, so the
input stream has already been consumed.

All you need to do in your action is use the form items you defined.
All the uploading will have been handled already by the time your
action is invoked.

Martin Cooper

> What cud be wrong?
> Thanks in advance
> Aathi

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

View raw message