commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Cooper <mart...@apache.org>
Subject Re: FileUpload problem/question
Date Fri, 23 Jan 2004 04:11:57 GMT
Is this in your own servlet, or in a Struts app, or where? If it's inside
Struts, then just remove it - Struts already handles file upload for you.
See the Struts documentation for the details.

--
Martin Cooper


On Thu, 22 Jan 2004, Brian Coakley wrote:

> I've used the code right from the upload example and I get no results from upload.parseRequest(request);
 There is other data on the page that is updating just fine.  Am I missing something obvious?
 Thanks, Brian Coakley
>
>       // Check that we have a file upload request
>       boolean isMultipart = FileUpload.isMultipartContent(request);
>       if(isMultipart){
>
>         // Create a new file upload handler
>         DiskFileUpload upload = new DiskFileUpload();
>
>         // Parse the request
>         List /* FileItem */ items = upload.parseRequest(request);
>
>         // Process the uploaded items
>         Iterator iter = items.iterator();
>         while (iter.hasNext()) {
>           FileItem item = (FileItem) iter.next();
>
>           if (item.isFormField()) {
>             // Process a regular form field
>             String name = item.getFieldName();
>               String value = item.getString();
>             } else {
>             // Process a file upload
>             String fieldName = item.getFieldName();
>               fileName = item.getName();
>               String contentType = item.getContentType();
>               boolean isInMemory = item.isInMemory();
>               long sizeInBytes = item.getSize();
>             }
>         }
>       }
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message