gpt4 book ai didi

liferay - Liferay 6.1 中的多个文件上传

转载 作者:行者123 更新时间:2023-12-02 02:15:16 24 4
gpt4 key购买 nike

有没有人在 Liferay 6.1 中尝试过多个文件上传。我试图以与 6.0 中相同的方式进行操作,但它严重失败。我看到页面左上角的开始链接,而不是 portlet。当我单击它并选择一些文件时,控件不会转到我的 portlet。我检查了我的 portlet.xml 并验证了 portlet 类是正确的。这是jsp中的片段

<liferay-portlet:actionURL doAsUserId="<%= user.getUserId() %>" windowState="pop_up" name="uploadFile" var="uploadFileURL" >
<portlet:param name="jspPage" value="/html/fileuploadportlet/view.jsp" />
</liferay-portlet:actionURL>


<div class="lfr-dynamic-uploader">
<div class="lfr-upload-container" id="<portlet:namespace />fileUpload"></div>
</div>
<div id="<portlet:namespace/>fallback"></div>
<aui:script use="liferay-upload">
new Liferay.Upload({
allowedFileTypes: '<%= StringUtil.merge(PrefsPropsUtil.getStringArray(PropsKeys.DL_FILE_EXTENSIONS, StringPool.COMMA)) %>',
container: '#<portlet:namespace />fileUpload',
maxFileSize: <%=Long.parseLong(PrefsPropsUtil.getString(PropsKeys.DL_FILE_MAX_SIZE)) %> / 1024,
namespace:'<%=renderResponse.getNamespace()%>',
uploadFile: '<%=uploadFileURL.toString()%>',
buttonHeight: 100,
buttonText: 'BEGIN',
buttonWidth: 100,
onFileComplete: function(){alert('fileComplete');},
onUploadError: function(){alert('error');}
});
</aui:script>

这是我的 portlet 的 processAction 方法

@Override
public void processAction(ActionRequest actionRequest,
ActionResponse actionResponse) throws IOException, PortletException {
System.out.println("Something");
UploadPortletRequest uploadRequest=PortalUtil.getUploadPortletRequest(actionRequest);
File file =uploadRequest.getFile("file");
System.out.println(file.getName());
for(int i=0;i<50000;i++){
System.out.println("Something");
}

}

Screenshot

最佳答案

你能检查一下你的 <aui:script>是正确的,下面是 html/portlet/document_library/upload_multiple_file_entries.jsp 中显示的内容,我认为您缺少属性 tempFileURL:

    <aui:script use="liferay-upload">
new Liferay.Upload(
{
allowedFileTypes: '<%= allowedFileExtensions %>',
container: '#<portlet:namespace />fileUpload',
deleteFile: '<liferay-portlet:actionURL doAsUserId="<%= user.getUserId() %>"><portlet:param name="struts_action" value="/document_library/edit_file_entry" /><portlet:param name="<%= Constants.CMD %>" value="<%= Constants.DELETE_TEMP %>" /><portlet:param name="folderId" value="<%= String.valueOf(folderId) %>" /></liferay-portlet:actionURL>&ticketKey=<%= ticket.getKey() %><liferay-ui:input-permissions-params modelName="<%= DLFileEntryConstants.getClassName() %>" />',
fileDescription: '<%= StringUtil.merge(PrefsPropsUtil.getStringArray(PropsKeys.DL_FILE_EXTENSIONS, StringPool.COMMA)) %>',
maxFileSize: '<%= PrefsPropsUtil.getLong(PropsKeys.DL_FILE_MAX_SIZE) %> B',
metadataContainer: '#<portlet:namespace />commonFileMetadataContainer',
metadataExplanationContainer: '#<portlet:namespace />metadataExplanationContainer',
namespace: '<portlet:namespace />',
tempFileURL: {
method: Liferay.Service.DL.DLApp.getTempFileEntryNames,
params: {
groupId: <%= scopeGroupId %>,
folderId: <%= folderId %>,
tempFolderName: 'com.liferay.portlet.documentlibrary.action.EditFileEntryAction'
}
},
uploadFile: '<liferay-portlet:actionURL doAsUserId="<%= user.getUserId() %>"><portlet:param name="struts_action" value="/document_library/edit_file_entry" /><portlet:param name="<%= Constants.CMD %>" value="<%= Constants.ADD_TEMP %>" /><portlet:param name="folderId" value="<%= String.valueOf(folderId) %>" /></liferay-portlet:actionURL>&ticketKey=<%= ticket.getKey() %><liferay-ui:input-permissions-params modelName="<%= DLFileEntryConstants.getClassName() %>" />'
}
);
</aui:script>

希望这对您有所帮助。

关于liferay - Liferay 6.1 中的多个文件上传,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10942980/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com