<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <script src="../bootstrap/js/bootstrap.min.js"></script> <script src="../bootstrap/js/jquery-1.11.2.min.js"></script> <link href="../bootstrap/css/bootstrap.min.css" /> </head> <style type="text/css"> .mulu{ background-color: #00AFF0; color: white; } </style> <body> <?php session_start(); $fname = "./qu"; //当前显示文件夹 if(!empty($_SESSION["fname"])){ $fname = $_SESSION["fname"]; } ?> <ul class="list-group"> <?php if($fname != "./qu"){ $prev = dirname($fname); echo "<li lj='{$prev}' class='list-group-item mulu'>返回上一层</li>"; } $d = opendir($fname); $arr = array(); $arr1 = array(); $arr2 = array(); while($name = readdir($d)){ if($name!="." && $name!=".."){ $path = $fname."/".$name; if(is_dir($path)){ $arr1[] = $path; }else{ $arr2[] = $path; } } } $arr = array_merge($arr1,$arr2); foreach($arr as $v){ $name = basename($v); if(is_dir($v)){ echo "<li lj='{$v}' class='list-group-item mulu'>{$name}</li>"; }else{ echo "<li class='list-group-item'>{$name}</li>"; } } closedir($d); ?> </ul> </body> <script> $(".mulu").DBLCLICK(function(){ var lj = $(this).attr("lj"); $.ajax({ type:"post", url:"chuli.php", async:true }); }) </script> </html> 处理页面 <?php session_start(); $lj = $_POST["lj"]; $_SESSION["fname"] = $lj;