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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] > Sent: Thursday, February 06, 2003 8:06 PM > To: [EMAIL PROTECTED] > 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 > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
