commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Martin Cooper" <martin.coo...@tumbleweed.com>
Subject RE: Apache File Upload program
Date Tue, 11 Feb 2003 05:28:53 GMT
First of all, you are more likely to receive a timely and helpful response
if you post your questions to the appropriate mailing list, as documented on
the FileUpload web page, rather than to individuals. I am cc'ing the
appropriate list on this reply.

For a form field, simply call FileItem.getString() to get the value of the
parameter.

For a file field, use FileItem.getFileName() to get the base name of the
uploaded file, and call FileItem.getInputStream() to access the contents.

--
Martin Cooper


> -----Original Message-----
> From: Alex.Ng@nokia.com [mailto:Alex.Ng@nokia.com]
> Sent: Thursday, February 06, 2003 8:06 PM
> To: martin.cooper@tumbleweed.com
> Subject: Apache File Upload program
> 
> 
> Hi Martin,
> 
> I am developing a web application. My web application needs 
> to allow user to upload file from
> browser to web server.  I found a good file upload Java 
> program at Apache website:
> http://jakarta.apache.org/commons/fileupload/team-list.html
> 
> I got it to work on my application. I would like to ask you 
> about retrieving a field
> value from a form. How do I get it to work ?
> 
> 	// Process the uploaded fields
>             Iterator iter = items.iterator();
>             while (iter.hasNext())
>             {
>                 FileItem item = (FileItem) iter.next();
> 
>                 if (item.isFormField())
>                 {
>                     System.out.println("Form name  -- " + 
> item.getFieldName());
> 	        System.out.println("Form value -- " + 
> req.getParameter(item.getFieldName()));	    
> 	    }
>                 else
>                 {
>                     System.out.println("File -- " + 
> item.getFieldName());
>                     System.out.println("File -- " + item.getName());
>                     item.write("d:\\temp\\upFile.txt");
>                 }
>             }
> 
> Your help is very much appreciated.
> 
> Alex
> 
> 


Mime
View raw message