barryvdh / laravel-elfinder

elFinder bundle for Laravel
745 stars 170 forks source link

config elfinder options #131

Open gzai opened 8 years ago

gzai commented 8 years ago

when I set setting options in config elfinder with the roots is null

'roots' => null,

'options' => array(
    'uploadAllow' => array(
        'image/png', 
        'image/jpg', 
        'image/pjpeg', 
        'image/jpeg',  
        'image/gif', 
        'image/bmp', 
        'image/x-windows-bmp', 
        'application/msword', 
        'application/excel', 
        'application/vnd.ms-excel', 
        'application/x-excel', 
        'application/x-msexcel', 
        'application/pdf', 
        'application/mspowerpoint', 
        'application/vnd.ms-powerpoint', 
        'application/mspowerpoint', 
        'application/powerpoint', 
        'application/vnd.ms-powerpoint', 
        'application/x-mspowerpoint', 
        'application/x-compressed', 
        'application/x-zip-compressed', 
        'application/zip', 'multipart/x-zip'
    ),
    'uploadDeny' => array(
        'all'
    ),
    'uploadOrder'=> array('deny', 'allow'),
),

upload allow and deny is not working. check the connector configuration options in wiki elfinder, uploadAllow, uploadDeny, and uploadOrder in array of roots first array.

so I change the code in vendor/barryvdh/laravel-elfinder/src/ElfinderController.php

public function showConnector()
{
    $roots = $this->app->config->get('elfinder.roots', []);
    if (empty($roots)) {
        $dirs = (array) $this->app['config']->get('elfinder.dir', []);
        foreach ($dirs as $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') // filter callback (OPTIONAL)
            ];
        }

        $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());
    // $opts = array_merge(['roots' => $roots], $opts);
    $roots[0] = array_merge($roots[0], $opts); // <- new code
    $opts = array('roots' => $roots); // <- new code

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

uploadAllow and uploadDeny is working now.

barryvdh commented 8 years ago

With the latest tag, I've added a root_options settings, which applies to all roots. Can you try that?

mmakhno commented 8 years ago

I've tried to use this options at root options array an it works. At least, it works for me :) Thank you!

gzai commented 8 years ago

yeah latest update root_options setting working for me to Thank you :)