Tuesday, July 21, 2015

How to Upload Multiple Files in Liferay


Today we will discuss how to upload multiple files in Single browse . We already discuss how to upload a Single file in my previous blog How to upload file in Liferay. Here we create a application where user can select multiple documents and upload in a single Click. Before reading this blog it is highly recommended to read my previous blogs on Document and Media Portlet in Detal ,  Upload Documents Programatically in Liferay  and How to upload files in Liferay.

So lets start this step by step:-





Step 1:-Create Liferay Project and Portlet
Create a Liferay Project in eclipse and then create a MVC portlet in the Project.For theses you may refer Step 1 and Step 2 of my previous blog Here .

Step 2:-Create Your Form
Open view.jsp and paste this code:-


Explanation:-

Here we set multiple="multiple" so that we can upload multiple files simultaneously.

Step 3:-Create portlet.properties
Create a property file in src with name portlet.properties and paste this content:-



Step 4:-Entry for thumbnails
If file is too large liferay not created thumbnail because default maximum size for thumbnail creation of file is 100MB only.Due to this a error comes as "File is too large for preview or thumbnail generation ".So open portal-ext.properties and paste this line and restart the Server.

dl.file.entry.previewable.processor.max.size=-1 




Step 5:-Create method in Java Class
Open your Java class and Paste this Content:-


Explanation:-

  • Here we fetch all the information related to file by UploadPortletRequest object and passing "uploadedFile" which is same as name attribute in our view.jsp for input type file.
  • All the method used in this class are already explained in my previous blog you can check it Here


Step 6:-Check Output
Now deploy your portlet add to page and Check the output as:-


You can Download Source code from How to Upload Multiple Files in Liferay.


Hope this will Help....

Related Post:-

No comments:

Post a Comment

Total Pageviews

Number Of Unique Visitor

Free counters!