elFinder界面打开时有没有办法打开特定文件夹?
我想通过js客户端中的参数或发送到php连接器的调用中的参数来设置文件夹,但找不到解决方案...
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/'
)
)
);
也许这可以帮助
startPath
已弃用且无法使用。使用startPathHash
您需要为您的路径生成哈希。
生成哈希:
https://github.com/Studio-42/elFinder/wiki/Getting-encoded-hash-from-the-path
也许您可以阅读此https://github.com/Studio-42/elFinder/issues/2597
'attributes' => array(
array(
'pattern' => '/^./', //You can also set permissions for file types by adding, for example, .jpg inside pattern.
'read' => true,
'write' => false,
'hidden' => false,
'locked' => true
),
array(
'pattern' => '/marketing/i', //You can also set permissions for file types by adding, for example, .jpg inside pattern.
'read' => true,
'write' => true,
'hidden' => false,
'locked' => false
),
array(
'pattern' => '/marketing$/i', //You can also set permissions for file types by adding, for example, .jpg inside pattern.
'read' => true,
'write' => true,
'hidden' => false,
'locked' => true
)
)
我正在使用 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();