我想要创建一个index.html文件,它将一个有序列表中目录中的所有文件链接起来。
例如,当您转到这里时,您会发现:
# 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>等等..。
发布于 2010-12-11 10:32:01
<?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值,这只是让您入门的一个示例。
发布于 2010-12-11 10:47:53
请如何使用PHP从目录中列出文件 回答得太频繁了在这里再次回答。但是,链接上的清单看起来很像Apache的内置目录索引,您可以通过
Options +Indexes在该文件夹中的.htaccess文件中。请参阅下列链接
https://stackoverflow.com/questions/4416222
复制相似问题