This content has been marked as final.
Show 1 reply
-
1. Re: portlets upload file problem
bdaw Oct 27, 2005 3:59 PM (in response to steean)When you have multipart form data your params will not be in params map directly but in multipart content along with file data. Use apache commons lib for this and try code below:
import org.apache.commons.fileupload.disk.DiskFileItemFactory; import org.apache.commons.fileupload.portlet.PortletFileUpload; import org.apache.commons.fileupload.FileItem; import org.apache.commons.fileupload.FileUploadException;
DiskFileItemFactory factory = new DiskFileItemFactory(); PortletFileUpload upload = new PortletFileUpload(factory); for (Iterator i = upload.parseRequest(req).iterator(); i.hasNext();) { FileItem item = (FileItem)i.next(); //for normal fields put them into request params map if (item.isFormField()) { req.getParameterMap().put(item.getFieldName(), new String[]{item.getString()}); } else { if (item.getSize() != 0) { /**here you can access file uploaded using: *item.getName() *item.getContentType() *item.get() *item.getName() *item.getSize() */ } } }
I hope this will help you.