To open the file directory, you must first obtain the file directory:
Add a hyperlink to the filemanager_html.php code to send a get request:
Code display:
<?php <!-- 循环输出目录列表--> <?php foreach ($file_list['dir'] as $v): ?> <tr><td><img src="./img/dir.png"><?php echo $v['filename'];?></td> <td><?php echo $v['filename'];?></td> <td>-</td> <td><a href="?path=<?php echo $v['filepath'];?>">打开</a></td> </tr> <?php endforeach;?>
Add the following code before the getFileList() function to obtain the get request To determine the path:
<?php //获取文件路径参数 $path=isset($_GET['path'])?$_GET['path']:'.'; //保存待处理文件名 $file=''; //判断$path路径是否存在 if(is_file($path)){ //如果是文件,则取出路径中的文件名 $file=basename($path); //将$path转换为目录 $path=dirname($path); }elseif (!is_dir($path)){ //既不是文件也不是目录,则程序停止 die('无效的文件路径参数'); }
Clicking on the directory folder will open the corresponding file directory and enter the next level directory
Directory display:
##Display before clicking: