posted 17 years ago
I should have posted this code to begin with but better late than never.
Here is my code. If I make a call to upload.parseRequest(req); after the code shown below, then the List that is returned is empty. I would like a way to reset the request so that I can pass it on to a handler function and parse the request again in the handler.
Thanks again for any help,
Billy
// Check that we have a file upload request
if (ServletFileUpload.isMultipartContent(req))
{
// Create a factory for disk-based file items
FileItemFactory factory = new DiskFileItemFactory();
// Create a new file upload handler
ServletFileUpload upload = new ServletFileUpload(factory);
// Parse the request
List /* FileItem */ fileItems = upload.parseRequest(req);
// Process the uploaded items
Iterator iter = fileItems.iterator();
while (iter.hasNext())
{
FileItem item = (FileItem) iter.next();
if (item.isFormField())
{
// Process a regular form field
sMsg += "FILE FORM FIELD - Name, Value: " + item.getFieldName() + ", " + item.getString() + "\n";
}
else
{
sMsg += "FILE UPLOAD - File Name: " + item.getName() + "\n";
sMsg += "FILE UPLOAD - Content Type: " + item.getContentType() + "\n";
sMsg += "FILE UPLOAD - IsInMemory: " + item.isInMemory() + "\n";
sMsg += "FILE UPLOAD - Size In Bytes: " + item.getSize() + "\n";
}
}