我想创建一个index.html文件,该文件链接有序列表中目录中的所有文件。
例如,当您转到here时,您会发现:
# Parent Directory
# <u>lol.html
# "><script>alert(String.fromCharCode(72)-String.fromCharCode(105)).html
# -AAAAAAAAAAAAAAAAAAAATESTING.html
# 0dl.blogspot.com.html
# 1000-suns.html
# 123-greeting.html
# 151.html
# 1^2+2-.-2^2-+-3^2-+2-.-4^2.html
# 2010-IIT-JEE-Solutions-Fiitjee.html
# 2010-IIT-JEE-Solutions.html
我想做什么:
<a href="http://searchr.us/web-search/<%3bu>%3blol.html" ><u>lol.html</a>
<a href="http://searchr.us/web-search/"%3b>%3b<%3bscript>%3balert(String.fromCharCode(72)-String.fromCharCode(105)).html">http://searchr.us/web-search/"%3b>%3b<%3bscript>%3balert(String.fromCharCode(72)-String.fromCharCode(105)).html</a>
等等......
答案 0 :(得分:1)
<?php
$dir = getcwd();
// Open a known directory, and proceed to read its contents
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
echo '<a href="'.$_SERVER['REQUEST_URI'].'/'.$file.'">' . $file . '</a><br />';
}
closedir($dh);
}
}
?>
小心必须更改a标签的href值,这只是一个让你入门的例子。
答案 1 :(得分:1)
How to list files from a directory with PHP has been answered way too often再次在此处回答。但是,该链接的列表看起来很像Apache的内置目录索引,您可以通过添加
来启用它Options +Indexes
在该文件夹中的.htaccess
文件中。请参阅以下链接