liferay tutorial

Thursday, February 24, 2011

Unable to upload with liferay, apache, liferay installe, java, jsp, java class, instructions, server, tomcat, action, upload portlet, servlet, liferay

giuseppe rossi :


Hello, I create a portlet, which simply took a file from the client, it loads on the server (where liferay, the latest version with tomcat, is installed) and saves it in a specific path. I used "apache commons upload" but it seems not to work, even though I followed the step by step the instructions (the JSP / HTML part and the Java class), but when I go to upload, it doesn't save the file on disk.








Any suggestions?








Thanks






Mazhar Anwar : You can easily upload a file on server.





Please make sure you have set form encType to 'multipart/form-data' in your jsp.








And then you can use "UploadPortletRequest" as in portal source "com.liferay.portlet.documentlibrary.action.EditFileEntryAction.java" for uploading the file on server.








No need to use apache commons uploads.








HTH.








Regards,

Mazhar






giuseppe rossi : Thanks for your answer. First I have already set encType. Then, do you mean this class?? http://docs.huihoo.com/javadoc/liferay/4.2/util-java/com/liferay/util/servlet/UploadPortletRequest.html








Because I can't understand how can I use that in a java class!






Mazhar Anwar : hmm, please find the sample code. You can pass ActionRequest/ResourceRequest/RenderRequest objects to the method.








liferay upload tutorial, liferay apache tutorial, liferay tomcat tutorial, liferay installation tutorial








PARAMETER_FILENAME is the name of your input tag for fileUplaod in jsp.






Mazhar Anwar : Package path for UploadPortletRequest is com.liferay.portal.kernel.upload.UploadPortletRequest emoticon






giuseppe rossi : it works...thanks ;)

1 comment:

  1. Is this PortalUtil.getUploadPortletRequest(actionRequest) working for resourceRequest obj ?

    I thought the above mentioned code only works in processAction() only . but could you tell me how can i do same upload thing in serveResource() method .........

    ReplyDelete