We already know how to upload file in document and media portlet. Today we will see how to upload a file in local machine . I created a folder on my desktop with name textdata. When we upload a file it will save in this folder . Here i also check that file must be a text file if you upload a pdf or jpeg it will give error.
So lets start this Step by Step:-
Step 1:-Create a project and portlet
Create a project and then create a portlet in it .Here my project name is upload-download-portlet and portlet name is Demo.
Step 2:-Change the jsp
Change your view.jsp as:-
view.jsp
Explanation:-
Here we create two urls :-
1)uploadURL:- Action URL for upload
2)downloadURL:- Resource URL(Ajax) for Download
Here we also use success and failure messages for Validation.
Step 3:-Change the Controller(Java)
Change the Portlet file as:-
Demo.java
Explanation:-
Here i created a folder textData on Desktop where i upload the file. File are save with name hello.txt.
Step 4:-Check the output
You can download the source code from here.
Related Post:-
Basic web content in Liferay
Categorization in web content
Structure and Template in Web Content
Fetch Web Content Programmatically
Get Journal Article Using SAX Parser
Form Handling in Spring Portlet
Embedding a Web Content in a Portlet
Fetch Latest Version Journal Article or Web Content in Liferay
No comments:
Post a Comment