Fórum
File Uploading problem
lucky singh, modificado 11 Anos atrás.
File Uploading problem
Junior Member Postagens: 25 Data de Entrada: 30/07/12 Postagens Recentes
Hey I have to create resume file upload option.
I am using ,
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.
I am using ,
UploadPortletRequest uploadRequest = PortalUtil.getUploadPortletRequest(request);
String submissionFileName = uploadRequest.getFileName("file");
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, modificado 11 Anos atrás.
RE: File Uploading problem
New Member Postagens: 17 Data de Entrada: 03/01/12 Postagens Recentes
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.
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, modificado 11 Anos atrás.
RE: File Uploading problem
Liferay Master Postagens: 894 Data de Entrada: 18/02/09 Postagens Recentes
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):
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
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):
#
# A file extension of * will permit all file extensions.
#
dl.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
Rashmi S, modificado 9 Anos atrás.
RE: File Uploading problem
New Member Postagens: 11 Data de Entrada: 03/01/14 Postagens Recentes
Hi All,
I am using below code snippet to upload a file.
<input type="file" class="multi
{ maxfile:2048,
accept:'gif|jpg|pdf|doc|docx|txt|dot|pps|ppt|pptx|tif|xls|xlsb|xlsx|zip',
STRING: {
remove:'X',
duplicate: 'duplicate',
denied:'invalid file .$ext',
toobig: '$file : too big"/>'
}
}" id="_attachments" name="_attach"/>
and following for fetch the uploaded file
UploadPortletRequest uploadRequest = PortalUtil.getUploadPortletRequest(request);
String fileName = uploadRequest.getFileName("file");
File file = uploadRequest.getFile("file");
Here file gets uploaded in /tomcat/temp directory, while debugging I came to know that the file immediately gets cleaned-up from temp. Due to which the file is uploaded without content i.e.,0k in document and media folder.
If anyone came across this issue, please suggest me in fixing this.
I am using below code snippet to upload a file.
<input type="file" class="multi
{ maxfile:2048,
accept:'gif|jpg|pdf|doc|docx|txt|dot|pps|ppt|pptx|tif|xls|xlsb|xlsx|zip',
STRING: {
remove:'X',
duplicate: 'duplicate',
denied:'invalid file .$ext',
toobig: '$file : too big"/>'
}
}" id="_attachments" name="_attach"/>
and following for fetch the uploaded file
UploadPortletRequest uploadRequest = PortalUtil.getUploadPortletRequest(request);
String fileName = uploadRequest.getFileName("file");
File file = uploadRequest.getFile("file");
Here file gets uploaded in /tomcat/temp directory, while debugging I came to know that the file immediately gets cleaned-up from temp. Due to which the file is uploaded without content i.e.,0k in document and media folder.
If anyone came across this issue, please suggest me in fixing this.