如何在elfinder中获取当前目录? [英] How to get current directory in elfinder?
本文介绍了如何在elfinder中获取当前目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用elfinder,但遇到了问题.我想在elfinder中获取当前目录,但是我不能.
I am using elfinder and I have a problem. I want to get current directory in elfinder but I can not.
已编辑: 这是我的连接器.由my_function组成,该函数在上载,重命名或mkdir命令后调用,我想在指定的位置获取上载的文件路径:
EDITED: this is my connector. consist of my_function that called after upload, rename or mkdir commands and I want to get uploaded files path in specified place:
<?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();
推荐答案
您可以获取商品网址.
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'];
}
}
}
或设为固有类ex elFinderVolumeMyLocalFileSystem
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)
),
)
);
这篇关于如何在elfinder中获取当前目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文