使用数组和数组在elFinder中添加多个根

时间:2017-09-14 06:58:57

标签: php arrays elfinder

我有一个JSON解码数组如下所示,它具有到根的路径。

BaseEntity

我们知道可以添加多个根,如下所示。

Digits.sharedInstance().start(withConsumerKey: "myConsumerKey", consumerSecret: "myConsumerSecret")

);

我想动态添加我的数组路径,如下所示。

$file_path = json_decode($_REQUEST['file_path']);

}

但问题是这会在每个对象的前面添加一个额外的键。如下。

$opts = array(
'roots' => array(
    array(
        'driver'        => 'LocalFileSystem',           // driver for accessing file system (REQUIRED)
        'path'          => 'path/to/files/first_root',  // path to files (REQUIRED)
        'URL'           => 'http://localhost/files/first_root/',   // URL to files (REQUIRED)
        'alias'         => 'First home', // The name to replace your actual path name. (OPTIONAL)
        'accessControl' => 'access'      // disable and hide dot starting files (OPTIONAL)
    ),
    array(
        'driver'        => 'LocalFileSystem',
        'path'          => 'path/to/files/second_root',
        'URL'           => 'http://localhost/files/second_root/',
        'alias'         => 'Second home'
    )
)

如何删除该附加数组键,或者是否有其他方法可以在elFinder中完成此任务。

1 个答案:

答案 0 :(得分:1)

最后我找到了解决方案。希望如果有人得到这个问题,这将有所帮助。

循环$ opts数组并将数据推送到'根'密钥并启动如下。

    $opts['roots'] = array();
foreach ($file_path as $path) {
    array_push($opts['roots'],array (
            'driver'        => 'LocalFileSystem',           // driver for accessing file system (REQUIRED)
            'path'          => "$path/",                 // path to files (REQUIRED)
            'URL'           => "$path", // URL to files (REQUIRED)
            'trashHash'     => 't1_Lw',                     // elFinder's hash of trash folder
            'winHashFix'    => DIRECTORY_SEPARATOR !== '/', // to make hash same to Linux one on windows too
            'uploadDeny'    => array('all', '*'),                // All Mimetypes not allowed to upload
            'uploadOrder'   => array('deny', 'allow'),      // allowed Mimetype `image` and `text/plain` only
            'accessControl' => 'access'                     // disable and hide dot starting files (OPTIONAL)
        )
    );
}

$connector = new elFinderConnector(new elFinder($opts));
$connector->run();