Search code examples
phpelfinder

elFinder - load path dynamically from user input


I have installed elFinder v2.1 File Manager on my local xampp server. Everything seems to be working fine. below is my connector.php;

function access($attr, $path, $data, $volume) {
return strpos(basename($path), '.') === 0
    ? !($attr == 'read' || $attr == 'write')
    :  null;}

$emp_id = 'sm_dir_name';
$opts = array(
    'bind' => array(
    'mkdir mkfile rename duplicate upload rm paste' => array($myLogger, 'log'),
       ),
       'roots' => array(
          array(
             'driver'         => 'LocalFileSystem',
             'path'           => '../../lib/lib_emp/'.$emp_id,
             'URL'            => dirname($_SERVER['PHP_SELF']) . '/../../lib/lib_emp/'.$emp_id, 
             'accessControl'  => 'access',             
             'uploadOverwrite'=> false,
        'debug'               => false,
        'arc'                 => '7za',
        'fileURL'             => true,
etc...;

This this my index.php file where I init the elFinder;

$(document).ready(function() {
var elf = $('#elfinder').elfinder({
           url             : 'css/connector.php',
           commandsOptions : {
              edit            : {
                        mimes : ['text/plain', 'text/html', 'text/javascript', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'], //types to edit
              editors: [{
                        mimes : ['text/plain', 'text/html', 'text/javascript', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'],
          load: function(textarea) {
            $(textarea).ckeditor();
          },
          close: function(textarea, instance) {
            CKEDITOR.instances[textarea.id].destroy();
          },
          save: function(textarea, editor) {
            textarea.value = $(textarea).val();
            }

          }
        ]
      }
   }
 }).elfinder('instance');
});

I have few questions as below;

  1. How to disable elFinder autoload when page loads?
  2. How to initiate elfinder to load with selected dir name(client should send value to server similar to $post method) I guess we can use customData : {token : '42', test : 'test'}, with elFinder initiate. I have no idea, how to retrieve these values from connector.php. Everytime user clicks on load_emp button, elFinder should refresh and direct to selected dir.

I am searching this and many more about elFinder since one month. The elFinder Developer team has very very poor documentation and support.

I am kindly requesting from you to answer this question, as well as future questions.

Best Regards,

Supun


Solution

  • How to disable elFinder autoload when page loads?

    Client configuration "rememberLastDir" (https://github.com/Studio-42/elFinder/wiki/Client-configuration-options-2.1#rememberLastDir)

    How to initiate elfinder to load with selected dir name

    Connector configuration "startPath" (https://github.com/Studio-42/elFinder/wiki/Connector-configuration-options-2.1#startPath)

    OR

    use URL hash

    ex)

    • hypweb.net/elFinder-nightly/demo/2.1/#elf_l2_Lw
    • hypweb.net/elFinder-nightly/demo/2.1/#elf_l1_V2VsY29tZQ