2015-04-05 66 views

回答

1

是的,我想动态获取哈希值。

这个怎么样。

$encode_func = function ($path, $root) { 
    $p = $path == $root ? '' : substr($path, strlen($root)+1) 
    if ($p === '') { 
     $p = DIRECTORY_SEPARATOR; 
    } 
    $hash = $this->crypt($p); 
    $hash = strtr(base64_encode($hash), '+/=', '-_.'); 
    $hash = rtrim($hash, '.'); 
    return $hash; 
}; 
$id = '[uniqueId]_'; You must set same id into root option 
$root = realpath('../image/data/'); 
$path = realpath('../image/data/product'); 
$hash = $id.$encode($path, $root); 
$url_hash = '#elf_'.$hash; 
2

elFinder 2.1可以直接打开URL散列的任何文件夹。

ex。

+0

由于之前。还有一个问题 - 如何生成散列?你能提供一个例子吗?假设我在connector.php \t'path'=>'../image/data/'和'URL'=>'../image/data/',并且需要打开../image/data/product/ – ymakux 2015-04-07 04:30:48

+0

请通过网络浏览器访问您的elFinder并将cwd更改为'product',然后检查位置栏。或者你想要动态获取哈希? – 2015-04-08 07:15:22

+0

是的,我想动态获取哈希。 – ymakux 2015-04-08 15:21:56

0

基于nao-pon和elfinder类的简单的东西。

第1步: //在php中从您的文件路径中创建散列,例如目录名( “根/图像/ iphone/iphone-6S.jpg”)。 它大多只是BASE64_ENCODE

function elfinder_hash_path($path) 
{ 
     if ($path == '') 
      $path = DIRECTORY_SEPARATOR; 
     $hash = substr($path, strlen("root-name")+1); 
     // hash is used as id in HTML that means it must contain vaild chars 
     // make base64 html safe and append prefix in begining 
     $hash = strtr(base64_encode($hash), '+/=', '-_.'); 
     // remove dots '.' at the end, before it was '=' in base64 
     $hash = rtrim($hash, '.'); 
     // append volume id to make hash unique 
     return "l1_". $hash; 
} 

“L1” 是elfinder自动卷ID为第一个本地文件系统。 否则,你可以在设置选项connector.php“ID” =>“身份识别码”你的卷ID,

第2步: 如果从JS调用elfinder窗口,elfinder初始化在此之后, 绑定elfinder onload事件跳到到你想要的目录。 在这种情况下,保存在JS变量hasher,从PHP获得。

var elf = $('#elfinder').elfinder({ 
    url : 'elfinder/php/connector.php', // connector URL (REQUIRED) 
    lang: 'sk', 
    height: okno_vyska 
}).elfinder('instance'); 

elf.bind('load', function(event) { elf.exec('open', hasher); }); 

更新:
elf.exec(“开放”,散列器)不工作,如果这个js会议散列子子目录​​尚未打开,因此它不是在缓存和elfinder什么都不做。
解决方法:要么使用本地存储
window.location.hash = hasher;
或更新上次使用的目录精灵的init

localStorage.setItem('elfinder-lastdirelfinder', hasher);