Search code examples
laravelfile-managerelfinder

Elfinder select folder as well as file in standalone popup


I am using elfinder as a file manager in one of my laravel project using barryvdh-elfinder package. I am using its standalone popup to let the user choose a file from existing files. But I want them to be able to choose folders as well. I can't seem to make it work.

Can anyone help me solve this problem. thanks.


Solution

  • As guided by Tiago A. ( thanks to him :) )we can use folder : true in commandsOptions while initializing elfinder like this:

    $('#elfinder').elfinder({
                // set your elFinder options here
                customData: {
                    _token: '<?= csrf_token() ?>'
                },
                url: '<?= URL::action('Barryvdh\Elfinder\ElfinderController@showConnector') ?>',  // connector URL
                dialog: {width: 900, modal: true, title: 'Select a file'},
                resizable: false,
                commandsOptions: {
                    getfile: {
                        oncomplete: 'destroy',
                        folders  : true
                    }
                },
                getFileCallback: function (file) {
                    window.parent.processSelectedFile(file.path, '<?= $input_id?>');
                    parent.jQuery.colorbox.close();
                }
            }).elfinder('instance');