[英]CKfinder multiple image upload without CKEditor
我正在使用沒有 CKEditor 的 ckfinder 模式將多個文件上傳到表單部分。
我使用了文檔部分提供的代碼,
CKfinder 模式按預期打開,選擇了多個文件,但我無法獲取所有圖像 url。 我只得到了第一張圖片的回應。
window.CKFinder = {
_popupOptions: {
'popup-1-config': { // Config ID for first popup
chooseFiles: true,
onInit: function( finder ) {
finder.on( 'files:choose', function( evt ) {
var file = evt.data.files.first();
var output = document.getElementById( 'output' );
output.innerHTML = 'Selected in popup 1: ' + file.get( 'name' ) + '<br>URL: <img src=" ' + file.getUrl() + '">';
} );
}
},
}
};
var popupWindowOptions = [
'location=no',
'menubar=no',
'toolbar=no',
'dependent=yes',
'minimizable=no',
'modal=yes',
'alwaysRaised=yes',
'resizable=yes',
'scrollbars=yes',
'width=800',
'height=600'
].join( ',' );
document.getElementById( 'popup-1-button' ).onclick = function() {
// Note that config ID is passed in configId parameter
window.open( 'http://foxhills.localhost/admin/ckfinder/ckfinder.html?popup=1&configId=popup-1-config', 'CKFinderPopup1', popupWindowOptions );
};
在上面的代碼中var file = evt.data.files.first(); 是我得到第一張圖片的原因。 我如何更改代碼以獲取所有 url 作為數組。
對於您的活動,請嘗試使用此測試
finder.on( 'files:choose', function( evt ) {
var files = evt.data.files;
var chosenFiles = '';
files.forEach( function( file, i ) {
chosenFiles += ( i + 1 ) + '. ' + file.get( 'name' ) + '\n';
} );
alert( chosenFiles );
} );
來源: https : //ckeditor.com/docs/ckfinder/ckfinder3/#!/api/CKFinder.Application-event-files_choose
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.