Hello,
I have written one portlet to upload the file to Document Library. bellow is the code.
JSP file 1
2<aui:form action="<%=actionURL%>" enctype="multipart/form-data" method="post" >
3
4 <aui:input name="user_id" label="User ID" disabled="true" value='${User_id }'/>
5 <aui:input name="file" inlineLabel="left" type="file" style="width: auto;"></aui:input>
6</aui:form>
File Upload Action file 1
2
3public void processAction(
4 ActionRequest actionRequest, ActionResponse actionResponse)
5 throws IOException, PortletException {
6
7 UploadPortletRequest uploadRequest = PortalUtil.getUploadPortletRequest(actionRequest);
8 String sourceFileName =uploadRequest.getFullFileName("file"); //getFileName("file");
9
10 System.out.println("sourceFile Full Name " + sourceFileName); // I am getting the sourceFile Full Name proper. When I am using enctype="multipart/form-data"
11 int userId = Integer.parseInt(actionRequest.getParameter("user_id")); // here I am getting Error
12
13 }
14}
Console LogsourceFile Full Name Fileupload.txt
Oct 3, 2012 10:07:44 AM org.apache.catalina.core.ApplicationDispatcher invoke
SEVERE: Servlet.service() for servlet createvisitportlet Servlet threw exception
java.lang.NumberFormatException: null
at java.lang.Integer.parseInt(Integer.java:417)
at java.lang.Integer.parseInt(Integer.java:499)
at com.navin.portal.portlet.FileUploadPortlet.processAction(FileUploadPortlet.java:55)
at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:70)
at com.liferay.portal.kernel.portlet.PortletFilterUtil.doFilter(PortletFilterUtil.java:48)
at com.liferay.portal.kernel.servlet.PortletServlet.service(PortletServlet.java:111)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
And when I am not using
enctype="multipart/form-data" inside Form tag , I am able to get the other data's inside the form tag. Please help me !!
Please sign in to flag this as inappropriate.