2015-04-05 64 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);