How to show a specific folder when the interface opens in elFinder?

时间秒杀一切 提交于 2019-12-11 20:09:11

问题


Is there a way to open a specific folder when the elFinder interface opens?

I want to set the folder, either by a parameter in the js client or a parameter in the call sent to the php connector, but can't find a solution...


回答1:


https://github.com/Studio-42/elFinder/wiki/Connector-configuration-options

$opts = array(
'roots'  => array(
    array(
        'driver' => 'LocalFileSystem',
        'path'   => '/path/to/files/',
        'startPath' => '/path/to/folder/to/open',
        'URL'    => 'http://localhost/to/files/'
    )       
)

);

maybe this can help




回答2:


I'm using laravel 5.1 and this is working to me

 public function showUserDir($user_id)
{

    $first_name = Auth::user()->first_name;
    $second_name = Auth::user()->second_name;
    $this->app = app();
    $roots = $this->app->config->get('elfinder.roots', []);
    if (empty($roots)) {
        $dirs = (array) $this->app['config']->get('elfinder.dir', []);
        $dirs[] = $dirs[0].DIRECTORY_SEPARATOR.$user_id;
        if(!is_dir($dirs[1])){
            mkdir($dirs[1], 0777, true);
        }
        foreach ($dirs as $key => $dir) {

                $roots[] = [
                    'driver' => 'LocalFileSystem', // driver for accessing file system (REQUIRED)
                    'path' => public_path($dir), // path to files (REQUIRED)
                    'URL' => url($dir), // URL to files (REQUIRED)
                    'accessControl' => $this->app->config->get('elfinder.access'),
                    'alias' => $first_name .' '.$second_name,
                    'uploadAllow' => array('image'),
                    'uploadMaxSize' => '10M',
                    'attributes' => array(
                        array(
                            'pattern' => '/\'/', // Dont write or delete to this but subfolders and files
                            'read' => true,
                            'write' => true,
                            'locked' => true
                        )
                    )
                ];

        }
        $disks = (array) $this->app['config']->get('elfinder.disks', []);
        foreach ($disks as $key => $root) {
            if (is_string($root)) {
                $key = $root;
                $root = [];
            }
            $disk = app('filesystem')->disk($key);
            if ($disk instanceof FilesystemAdapter) {
                $defaults = [
                    'driver' => 'Flysystem',
                    'filesystem' => $disk->getDriver(),
                    'alias' => $key,
                ];
                $roots[] = array_merge($defaults, $root);
            }
        }
    }

    $opts = $this->app->config->get('elfinder.options', array());
    $bind = array(
        'upload.presave' => array(
            'Plugin.Watermark.onUpLoadPreSave'
        )
    );

    $opts = array_merge(['bind'=>$bind,'plugin'=>$plugin,'roots' => $roots], $opts);

    // run elFinder
    $elfinder = new \elFinder($opts);
    $connector = new Connector($elfinder);
   // dd($connector);
    $connector->run();
    return $connector->getResponse();
}

For Laravel 4 Elfinder plugin you can use

$dir = $this->app->config->get($this->package . '::dir').'/'.$patient_id;
    $roots = $this->app->config->get($this->package . '::roots');



    if (!$roots)
    {
        $roots = array(
            array(
                'driver' => 'LocalFileSystem', // driver for accessing file system (REQUIRED)
                'path' => $this->app['path.public'] . DIRECTORY_SEPARATOR . $dir, // path to files (REQUIRED)
                'URL' => $this->app['url']->asset($dir), // URL to files (REQUIRED)
                'accessControl' => $this->app->config->get($this->package . '::access') // filter callback (OPTIONAL)
            )
        );
    }

    $opts = $this->app->config->get($this->package . '::options', array());
    $opts = array_merge(array(
            'roots' => $roots
        ), $opts);

    // run elFinder
    $connector = new Connector(new \elFinder($opts));
    $connector->run();
    return $connector->getResponse();


来源:https://stackoverflow.com/questions/33045155/how-to-show-a-specific-folder-when-the-interface-opens-in-elfinder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!