Как показать конкретную папку, когда интерфейс открывается в elFinder?

Есть ли способ открыть определенную папку при открытии интерфейса elFinder?

Я хочу установить папку, либо параметром в клиенте js, либо параметром в вызове, отправляемом на php-коннектор, но не могу найти решение …

0

Решение

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/'
)
)

);

может быть, это может помочь

1

Другие решения

Я использую Laravel 5.1, и это работает для меня

 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();
}

Для плагина Laravel 4 Elfinder вы можете использовать

$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();
0