Primefaces文件上传,将文件放在p:fileUpload以外的任何地方 [英] Primefaces File upload, Drop file outside of p:fileUpload anywhere in the page
问题描述
我试图手动触发drop事件对于primefaces上传组件,但这是行不通的。
请帮助我。
这是我试过的,
$ ('.otherdropzone')。on('dragover',function(e){e.preventDefault();}); ('dragenter',function(e){e.preventDefault();});
$('。otherdropzone')。 ('。drop',function(e){
e.preventDefault();
$(。fileupload ('drop',e); // Primefaces dropzone cssclass
});
通过更改Primefaces的触发器和放置区类(例如.files和.ui)的参数-fileupload
诀窍是Primefaces开发了基于 Fileupload
在下面的插件。所以,我开始在那里工作在primefaces
https://github.com/blueimp/jQuery-File-Upload/wiki/API
只要将 id
设为< p:fileUpload /> $ c
< p:fileUpload id =advanceduploadwidgetVar =advupload
fileUploadListener = #{fileUploadController.handleFileUpload}
mode =advanceddragDropSupport =truemultiple =true
update =messagessizeLimit =10000000fileLimit =2
allowTypes = /(\.|\/)(gif|jpe?g|png|pdf)$//>
在此基础上,它将在浏览器中呈现为 HTML5文件上传组件。
因此,脚本
将会是
$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $' )
});
});
应该是 In primefaces file upload, FileUpload component itself is the drop zone. I want to create multiple dropzones, for example if user drops files on any other div or table the Primefaces File upload component should pick that. I tried to trigger drop event manually for primefaces upload component but this is not working. Please help me with this. Thanks in advance! Here is what I tried, Similar other things by changing arguments for trigger and drop zone class of Primefaces such as .files and .ui-fileupload The trick is Primefaces have developed the Just give a and based on this it will render as So, Should be 这篇关于Primefaces文件上传,将文件放在p:fileUpload以外的任何地方的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! $(window).load()$ c $否则它会抱怨在DOM中找不到的组件。这就是诀窍。
$('.otherdropzone').on( 'dragover', function(e) { e.preventDefault(); } );
$('.otherdropzone').on( 'dragenter', function(e) { e.preventDefault(); } );
$(".otherdropzone").on('drop', function(e){
e.preventDefault();
$(".fileupload-content").trigger('drop',e); // Primefaces dropzone cssclass
});
Fileupload
functionality based on below plugin.So, I started there and got it working in primefaces
id
to <p:fileUpload/>
tag like <p:fileUpload id="advancedupload" widgetVar="advupload"
fileUploadListener="#{fileUploadController.handleFileUpload}"
mode="advanced" dragDropSupport="true" multiple="true"
update="messages" sizeLimit="10000000" fileLimit="2"
allowTypes="/(\.|\/)(gif|jpe?g|png|pdf)$/" />
HTML5 File Upload component in the browser
.script
will be $(window).load(function(){
$('#advancedupload').fileupload({
dropZone: $(document)
});
});
$(window).load()
otherwise it complain about component not found in DOM. That's it does the trick.