Hello All,
If I put follwing code in
JSP , It works fine and uploads the file
boolean isMultipart = FileUpload.isMultipartContent(request);
System.out.println("MultiPart is "+isMultipart);
DiskFileUpload upload = new DiskFileUpload();
// Set upload parameters
upload.setSizeMax(1000000);
List /* FileItem */ items = upload.parseRequest(request);
System.out.println("items.size =" + items.size());
Iterator itr = items.iterator();
while(itr.hasNext()) {
FileItem fi = fi= (FileItem)itr.next();
//Check if not form field so as to only handle the file inputs
//else condition handles the submit button input
if(!fi.isFormField()) {
System.out.println("\nNAME: "+fi.getName());
System.out.println("SIZE: "+fi.getSize());
//System.out.println(fi.getOutputStream().toString());
System.out.println("App.getrealpath() ="+ servlet.getServletContext().getRealPath("/") );
File fNew= new File(servlet.getServletContext().getRealPath("/"), fi.getName());
System.out.println(fNew.getAbsolutePath());
fi.write(fNew);
}
else {
System.out.println("Field ="+fi.getFieldName());
}
}
but If I put that code in Action Class , List /* FileItem */ items is empty set, i.e items.size is ZERO !!
Can anybody enlighten me on this ??
Thanks in Advance.
-Anand.