Open file directory operation
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 <!-- 循環(huán)輸出目錄列表--> <?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 //獲取文件路徑參數(shù) $path=isset($_GET['path'])?$_GET['path']:'.'; //保存待處理文件名 $file=''; //判斷$path路徑是否存在 if(is_file($path)){ //如果是文件,則取出路徑中的文件名 $file=basename($path); //將$path轉換為目錄 $path=dirname($path); }elseif (!is_dir($path)){ //既不是文件也不是目錄,則程序停止 die('無效的文件路徑參數(shù)'); }
Clicking on the directory folder will open the corresponding file directory and enter the next level directory
Directory display:
##Display before clicking: