-1

我正在使用 elfinder,但我遇到了问题。我想在 elfinder 中获取当前目录,但我不能。

编辑: 这是我的连接器。由在上传、重命名或 mkdir 命令后调用的 my_function 组成,我想在指定位置获取上传的文件路径:

    <?php

error_reporting(0); // Set E_ALL for debuging
include_once dirname(__FILE__).DIRECTORY_SEPARATOR.'elFinderConnector.class.php';
include_once dirname(__FILE__).DIRECTORY_SEPARATOR.'elFinder.class.php';
include_once dirname(__FILE__).DIRECTORY_SEPARATOR.'elFinderVolumeDriver.class.php';
include_once dirname(__FILE__).DIRECTORY_SEPARATOR.'elFinderVolumeLocalFileSystem.class.php';

function access($attr, $path, $data, $volume) {
    return strpos(basename($path), '.') === 0       // if file/folder begins with '.' (dot)
        ? !($attr == 'read' || $attr == 'write')    // set read+write to false, other (locked+hidden) set to true
        :  null;                                    // else elFinder decide it itself
}


function my_function($cmd, $result, $args, $elfinder)
{
  // how to get current path here?
}

$opts = array(
  'bind' => array('upload rename mkdir' => 'my_function'),
    // 'debug' => true,
    'roots' => array(
        array(
            'driver'        => 'LocalFileSystem',   // driver for accessing file system (REQUIRED)
            'path'          => '../files/',         // path to files (REQUIRED)
            'URL'           => dirname($_SERVER['PHP_SELF']) . '/../files/', // URL to files (REQUIRED)
            'accessControl' => 'access'             // disable and hide dot starting files (OPTIONAL)
        ),
    )
);

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

1 回答 1

0

您可以获取项目 URL。

function my_function($cmd, $result, $args, $elfinder)
{
    // how to get current path here?
    foreach ($result['added'] as $file) {
        if (!empty($file['url']) && $file['url'] !=  1) {
            $url = $file['url'];
        }
    }
}

或使固有类 exelFinderVolumeMyLocalFileSystem

class elFinderVolumeMyLocalFileSystem extends elFinderVolumeLocalFileSystem
{
    public function decode($hash) {
        return parent::decode($hash);
    }
}

function my_function($cmd, $result, $args, $elfinder)
{
    // how to get current path here?
    foreach ($result['added'] as $file) {
        if ($volume = $elfinder->getVolume($file['hash'])) {
            $dir = $volume->decode($file['phash']);
        }
    }
}

$opts = array(
  'bind' => array('upload rename mkdir' => 'my_function'),
    // 'debug' => true,
    'roots' => array(
        array(
            'driver'        => 'MyLocalFileSystem',   // driver for accessing file system (REQUIRED)
            'path'          => '../files/',         // path to files (REQUIRED)
            'URL'           => dirname($_SERVER['PHP_SELF']) . '/../files/', // URL to files (REQUIRED)
            'accessControl' => 'access'             // disable and hide dot starting files (OPTIONAL)
        ),
    )
);
于 2015-03-20T06:22:25.820 回答