
<script type="text/javascript" src="http://static.jstree.com/v.1.0pre/jquery.js"></script>
<script type="text/javascript" src="http://static.jstree.com/v.1.0pre/_docs/syntax/!script.js"></script>
<script type="text/javascript" src="http://static.jstree.com/v.1.0pre/jquery.cookie.js"></script>
<script type="text/javascript" src="http://static.jstree.com/v.1.0pre/jquery.hotkeys.js"></script>
<script type="text/javascript" src="http://static.jstree.com/v.1.0pre/jquery.jstree.js"></script>



<script>

$(document).ready(function(){ 
    //fill data to tree  with AJAX call
    $('#sidebar').jstree({
        'core' : {
            'data' : {
                "url" : "tree_data.php",
                "dataType" : "json" // needed only if you do not supply JSON headers
            }
        }
    }) 
});


//echo json_encode(['id'=>-1, 'text'=>'Blog Posts', 'children'=>$nodes, 'state'=>['opened'=>true]]);
</script>


<?php
// Désactiver le rapport d'erreurs


error_reporting(0);

function ListFolder($path)
{
    //using the opendir function
    $dir_handle = @opendir($path) or die("Unable to open $path");
   
    //Leave only the lastest folder name
    $dirname = end(explode("/", $path));
   
    //display the target folder.
    echo ("<li>$dirname\n");
    echo "<ul>\n";
    while (false !== ($file = readdir($dir_handle)))
    {
        if($file!="." && $file!="..")
        {
            if (is_dir($path."/".$file))
            {
                //Display a list of sub folders.
                ListFolder($path."/".$file);
            }
            else
            {
                //Display a list of files.
                echo "<li>$file</li>";
            }
        }
    }
    echo "</ul>\n";
    echo "</li>\n";
   
    //closing the directory
    closedir($dir_handle);
}

ListFolder("../Utilisateurs");

?>