我正在尝试返回jstree中所选节点的路径.我需要节点的整个路径.
我有一个生成json的php文件,如下所示:
header("Content-Type: application/json; charset=utf8");
echo json_encode(dir_to_jstree_array("/my_path"));
function dir_to_jstree_array($dir, $order = "a", $ext = array()) {
if(empty($ext)) {
$ext = array ("jpg", "gif", "jpeg", "png", "doc", "xls", "pdf", "tif", "ico", "xcf", "gif87", "scr" );
}
$listDir = array(
'text' => basename($dir),
'icon' => 'jstree-folder',
'children' => array()
);
$files = array();
$dirs = array();
if($handler = opendir($dir)) {
while (($sub = readdir($handler)) !== FALSE) {
if ($sub != "." && $sub != "..") {
if(is_file($dir."/".$sub)) {
$extension = trim(pathinfo($dir."/".$sub, PATHINFO_EXTENSION)); …Run Code Online (Sandbox Code Playgroud)