[英]Directory browsing in PHP
I'm want to write a PHP code where I want to browse through multiple directories in a web browser. 我想编写一个PHP代码,以便在Web浏览器中浏览多个目录。 My directory structure is something like this: 我的目录结构是这样的:
MAIN DIR
-> SUB DIR1
-> sub dir1
-> *downloadable PDF files*
-> sub dir2
-> *downloadable PDF files*
-> sub dir3
-> *downloadable PDF files*
-> SUB DIR2
-> sub dir1
-> *downloadable PDF files*
-> sub dir2
-> *downloadable PDF files*
-> sub dir3
-> *downloadable PDF files*
-> SUB DIR3
-> sub dir1
-> *downloadable PDF files*
-> sub dir2
-> *downloadable PDF files*
-> sub dir3
-> *downloadable PDF files*
So far I'm only able to list the directories. 到目前为止,我只能列出目录。 Can anyone help me in how should I move ahead? 谁能帮助我前进? I'm using lighttpd
server. 我正在使用lighttpd
服务器。
try this code you will get all list in arrays
function dirToArray($dir) {
$result = array();
$cdir = scandir($dir);
foreach ($cdir as $key => $value)
{
if (!in_array($value,array(".","..")))
{
if (is_dir($dir . DIRECTORY_SEPARATOR . $value))
{
$result[$value] = dirToArray($dir . DIRECTORY_SEPARATOR . $value);
}
else
{
$result[] = $value;
}
}
}
return $result;
}
完全不同的选择是使用mod_webdav并使用WebDAV浏览文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.