Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
lucky singh
File Uploading problem
November 19, 2012 10:48 PM
Answer

lucky singh

Rank: Junior Member

Posts: 26

Join Date: July 30, 2012

Recent Posts

Hey I have to create resume file upload option.
I am using ,
1 UploadPortletRequest uploadRequest = PortalUtil.getUploadPortletRequest(request);
2      String submissionFileName = uploadRequest.getFileName("file");
3      File submissionFile = uploadRequest.getFile("file");

Here file gets uploaded in /tomcat/temp directory.

I have following problems that I am facing:

1)All files are not supported - I tried .txt not supported,though pdf, doc, xml is supported.
2)When I redeploy portlet on server my files disapper from temp.
3)How can I specify path to upload my files other than default temp folder, i.e I want to store in document & media.
4)My file name changes when stored in temp folder.
Hiral Barot
RE: File Uploading problem
November 20, 2012 1:52 AM
Answer

Hiral Barot

Rank: New Member

Posts: 16

Join Date: January 3, 2012

Recent Posts

Hi Lucky,

1)First of all we need to create directory for adding documents and for that we can use following API.

DLServiceUtil.addDirectory(companyId, repositoryId, dirName);
//Where repositoryId is CompanyConstants.SYSTEM;

2)Now for adding file in that directory we can use :
DLServiceUtil.addFile(
companyId, portletId, groupId,repositoryId,
dirName + StringPool.SLASH + fileName, 0, StringPool.BLANK,
new Date(), new String[0], new String[0], bytes);

These steps will store file under "data" folder in tomcat.
Oliver Bayer
RE: File Uploading problem
November 20, 2012 1:52 AM
Answer

Oliver Bayer

Rank: Liferay Master

Posts: 751

Join Date: February 18, 2009

Recent Posts

Hi,

regarding your questions:

1) Use the following property to define which file types are allowed (the setting in the control panel overrides the one in portal-ext.properties):
1#
2# A file extension of * will permit all file extensions.
3#
4dl.file.extensions=*

2+3+4) As the folder name "temp" states it's only for temporary files. If you need the file to be persisted take a look at the DLFileEntryLocalServiceUtil methods and the document library portlet in general.

HTH Oli