我希望将此作为一种安全形式,用于托管我的计算机上的文件。我想知道我是否能够使用php中的头函数返回localhost中的文件夹视图,或者我是否只能使用它去其他文件。
if(ISSET($_POST['submit'])){
if($_POST['pass']=="password"){
header("Location:\Other");
}
}
答案 0 :(得分:0)
你可以这样做:
<?php
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;
}
if(!empty($_POST)) {
if($_POST['password'] == 'yoursecretpassword') {
$dir = './efgh';
print_r(dirToArray($dir));
}
}
?>
<form action="<? $_SERVER['PHP_SELF']; ?>" method="POST">
<input type="password" name="password">
<input type="submit" value="Submit">
</form>
答案 1 :(得分:0)
这是我的整个php文档:
mininext> pingall
*** Ping: testing ping reachability
a1 -> b1 c1 d1 h1 h2 h3 h4 h5 h6 h7 h8
b1 -> a1 c1 d1 h1 h2 h3 h4 h5 h6 h7 h8
c1 -> a1 b1 d1 h1 h2 h3 h4 h5 h6 h7 h8
d1 -> a1 b1 c1 h1 h2 h3 h4 h5 h6 h7 h8
h1 -> a1 b1 c1 d1 h2 h3 h4 h5 h6 h7 h8
h2 -> a1 b1 c1 d1 h1 h3 h4 h5 h6 h7 h8
h3 -> a1 b1 X d1 h1 h2 h4 h5 h6 X h8
h4 -> a1 b1 c1 d1 h1 h2 h3 h5 h6 h7 h8
h5 -> a1 b1 c1 X h1 h2 h3 h4 h6 h7 h8
h6 -> a1 b1 X d1 h1 h2 h3 h4 h5 h7 h8
h7 -> a1 b1 c1 d1 h1 h2 h3 h4 h5 h6 h8
h8 -> a1 b1 c1 d1 h1 h2 h3 h4 h5 h6 h7
*** Results: 3% dropped (128/132 received)
mininext> pingall
*** Ping: testing ping reachability
a1 -> b1 c1 d1 h1 h2 h3 h4 h5 h6 h7 h8
b1 -> a1 c1 d1 h1 h2 h3 h4 h5 h6 h7 h8
c1 -> a1 b1 d1 h1 h2 h3 h4 h5 h6 h7 h8
d1 -> a1 b1 c1 h1 h2 h3 h4 h5 h6 h7 h8
h1 -> a1 b1 c1 X h2 h3 h4 h5 h6 h7 h8
h2 -> a1 b1 c1 d1 h1 h3 h4 h5 h6 h7 h8
h3 -> a1 b1 c1 d1 h1 h2 h4 h5 h6 h7 h8
h4 -> a1 b1 c1 d1 h1 h2 h3 h5 h6 h7 h8
h5 -> a1 b1 c1 d1 h1 h2 h3 h4 h6 h7 h8
h6 -> a1 b1 c1 d1 h1 h2 h3 h4 h5 h7 h8
h7 -> a1 b1 c1 d1 h1 h2 h3 h4 h5 h6 h8
h8 -> X b1 c1 d1 h1 h2 h3 h4 h5 h6 h7
*** Results: 1% dropped (130/132 received)
mininext> pingall
*** Ping: testing ping reachability
a1 -> b1 c1 d1 h1 h2 h3 h4 h5 h6 h7 h8
b1 -> a1 c1 d1 h1 h2 h3 h4 h5 h6 h7 h8
c1 -> a1 b1 d1 h1 h2 h3 h4 h5 h6 h7 h8
d1 -> a1 b1 c1 h1 h2 h3 h4 h5 h6 h7 h8
h1 -> a1 b1 c1 d1 h2 h3 h4 h5 h6 h7 h8
h2 -> a1 b1 c1 d1 h1 h3 h4 h5 h6 h7 h8
h3 -> a1 b1 c1 d1 h1 h2 h4 h5 h6 h7 h8
h4 -> X b1 c1 d1 h1 h2 h3 h5 h6 h7 h8
h5 -> a1 b1 c1 d1 h1 h2 h3 h4 h6 h7 h8
h6 -> a1 b1 c1 d1 h1 h2 h3 h4 h5 h7 h8
h7 -> a1 b1 c1 d1 h1 h2 h3 h4 h5 h6 h8
h8 -> a1 b1 c1 d1 h1 h2 h3 h4 h5 h6 h7
*** Results: 0% dropped (131/132 received)
mininext> pingall
*** Ping: testing ping reachability
a1 -> b1 c1 d1 h1 h2 h3 h4 h5 h6 h7 h8
b1 -> a1 c1 d1 h1 h2 h3 h4 h5 h6 h7 h8
c1 -> a1 b1 d1 h1 h2 h3 h4 h5 h6 h7 h8
d1 -> a1 b1 c1 h1 h2 h3 h4 h5 h6 h7 h8
h1 -> a1 b1 c1 d1 h2 h3 h4 h5 h6 h7 h8
h2 -> a1 b1 c1 d1 h1 h3 h4 h5 h6 h7 h8
h3 -> a1 b1 c1 d1 h1 h2 h4 h5 h6 h7 h8
h4 -> a1 b1 c1 d1 h1 h2 h3 h5 h6 h7 h8
h5 -> a1 b1 c1 X h1 h2 h3 h4 h6 h7 h8
h6 -> a1 b1 c1 d1 h1 h2 h3 h4 h5 h7 h8
h7 -> a1 b1 c1 d1 h1 h2 h3 h4 h5 h6 h8
h8 -> X b1 c1 d1 h1 h2 h3 h4 h5 h6 h7
*** Results: 1% dropped (130/132 received)
mininext> pingall
*** Ping: testing ping reachability
a1 -> b1 c1 d1 h1 h2 h3 h4 h5 h6 h7 h8
b1 -> a1 c1 d1 h1 h2 h3 h4 h5 h6 h7 h8
c1 -> a1 b1 d1 h1 h2 h3 h4 h5 h6 h7 h8
d1 -> a1 b1 c1 h1 h2 h3 h4 h5 h6 h7 h8
h1 -> a1 b1 c1 X h2 h3 h4 h5 h6 h7 h8
h2 -> a1 b1 c1 d1 h1 h3 h4 h5 h6 h7 h8
h3 -> a1 b1 c1 d1 h1 h2 h4 h5 h6 h7 h8
h4 -> a1 b1 c1 d1 h1 h2 h3 h5 h6 h7 h8
h5 -> a1 b1 c1 d1 h1 h2 h3 h4 h6 h7 h8
h6 -> a1 b1 c1 d1 h1 h2 h3 h4 h5 h7 h8
h7 -> a1 b1 c1 d1 h1 h2 h3 h4 h5 h6 h8
h8 -> X b1 c1 d1 h1 h2 h3 h4 h5 h6 h7
*** Results: 1% dropped (130/132 received)
这是我的文件夹结构:
现在它给了我这个错误:
<强>禁止强>
您无权访问/ Files /&lt;在这台服务器上。