Search code examples
htmlfile-uploaduploadliferayliferay-6

Upload Doc in Lifery + Insert Information in Database


I have one for with 4-5 fields and one Upload button for Uploading One document. I have also created Tables(Service.xml) for the same. I successfully upload the document into Document Library of the Liferay and also done with Database but when i combine both this together i started getting errors.

Here is the Code:-

<portlet:actionURL var="uploadRFPUrl" name="uploadRFP"></portlet:actionURL>

<form action="<%= uploadRFPUrl %>" method="POST" id="form1" enctype="multipart/form-data">

    <input name="redirect" value="<%= redirect %>" type="hidden"></input>


    RFP Name :- <input name="rfpName"></input><br/><br/>

    Client Name :- <input name="clientName"></input><br/><br/>

    Client Region :-<input name="clientRegion"></input><br/><br/>

    Description :- <input name="description"></input><br/><br/>

    Previous Related Project : -<input name="prevRelatedProjects"></input> <br/><br/>

    RFP DOC ID :- <input name="rfpDocId"></input> <br/><br/>

    Due Date :- <input name="dueDate" /><br/><br/>

<input type="file" name="rfpdocPath" />

When I run it is not storing the data but when i remove enctype="multipart/form-data" from the form it stores the data into database but it gives me error. So Where i am making mistake please if anyone has idea let me know. Its urgent for me to complete it today..

Thanks


Solution

  • You need to use

    UploadPortletRequest uploadRequest = PortalUtil.getUploadPortletRequest(request);
    

    from this u can get the form attributes value..

    example

    ParamUtil.getLong(uploadRequest, "txtId")