将下述代码放到Web服务器并修改s_fileRoot
参数位您需要展示的目录即可。
代码如下:
<?php
$s_fileRoot = './';
chdir($s_fileRoot);
$r_file = null;
$a_fileInfo = [];
if(isset($_GET['filename'])){
$s_fileRoot = $_GET['filename'];
}
if(isset($_GET['back'])){
$s_fileRoot = $_GET['backPath'];
}
if(isset($_GET['downloadFilePath'])){
$downloadFilePath = $_GET['downloadFilePath'];
$downloadFileName = $_GET['downloadFileName'];
header("Content-Type:application/octet-stream");
header("Content-Disposition:attachment;filename=$downloadFileName");
echo file_get_contents($downloadFilePath);
exit();
}
if(is_dir($s_fileRoot)){
$r_file = opendir($s_fileRoot);
while(false !== (