I am working on the file manager using jquery
here is the code:
var elfinder = $('#elfinder').elfinder({
url: '<?= $connector; ?>',
soundPath: '<?= site_url('assets/plugins/elFinder/sounds/rm.wav'); ?>',
height: 700,
lang: 'zh_TW',
uiOptions: {
// toolbar configuration
toolbar: [
['back', 'forward'],
['reload'],
['mkdir', 'upload'],
['copy', 'cut', 'paste', 'rm'],
['rename'],
['view', 'sort']
]
},
contextmenu: {
navbar: ['open', '|', 'copy', 'cut', 'paste', 'duplicate', '|', 'rm', '|', 'info'],
cwd: ['reload', 'back', '|', 'upload', 'mkdir', 'paste', '|', 'info'],
files: [
'open', 'quicklook', 'sharefolder', '|', 'download', '|', 'copy', 'cut', 'paste', 'rm', '|', 'rename', '|', 'info'
]
},
ui: ['toolbar', 'tree', 'stat'],
handlers: {
add: function (e) {
},
upload: function (e, instance) {
alert("test1");
//alert("test2");
//return false;
//console.log(event.data);
//console.log(event.data.selected); // selected files hashes list
}
}
});
The problem are,
1) I would like to have some checking before file upload, if fail then cancel the upload, but in either add / upload event it is fire after upload start , and fire several time
2) Also, it can't capture the on upload complete event as the upload event fire several time
Here is the event list:
https://github.com/Studio-42/elFinder/wiki/Client-event-API
Any suggestion , thanks a lot for helping.
Updated:
Find in Server side, there is a bind options , to override the command e.g. "rm mkdir" etc... however , I would like to get the user id when store, so are there list of event that I can override in client side? Thanks
https://github.com/Studio-42/elFinder/wiki/Connector-configuration-options
Please override the function because there is no hook point before command execution.
var elfinderInstance = $('#elfinder').elfinder({ /* Your options */ }).elfinder('instance');
elfinderInstance.upload = function(files) {
var hasError;
elfinderInstance.log(files); // print to browser consol
if (hasError) {
elfinderInstance.error('upload error');
return $.Deferred().reject();
} else {
return elfinderInstance.transport.upload(files, elfinderInstance);
}
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With