【发布时间】:2015-02-16 11:35:56
【问题描述】:
我正在开发一个应用程序,如果满足某个条件,可以通过按下按钮来创建文件夹。问题是该文件夹是使用 mkdir () 创建的,不明白为什么。甚至 html 页面都告诉我该文件夹已创建,但这并没有出现在目录中。我不明白这个错误。代码如下:
<html>
<head>
<title>RHM</title>
<style type="text/css">
h1 { color: red; font-family: arial; font-size: 3em; font-weight: bolder; }
p { color: navy; font-family: Verdana; }
</style>
</head>
<body>
<h1 align="center">INGRESE CONTRASEÑA</h1>
<form action="#" method="post" >
<p align="center"> <input type="password" name="contras" style="width:200px;height:50px;background-color:yellow;color:blue;font-size:14pt;font-family: Comic Sans MS;text-align:center;padding-right:10px;"/></p>
<p align="center" ><input type="submit" value="Entrar" /></p>
<?php
$Contraseña=$_POST['contras'];
$estructura = "/home/bladimir/RHMbd";
if ($Contraseña==1) {
mkdir($estructura);
echo "<p>La carpeta fue creada</p>";
}
?>
</form>
</body>
</html>
谢谢。
【问题讨论】:
-
当你说«但是这并没有出现在目录中»时,您是在检查服务器端还是客户端? php用户是否有权创建子目录?
-
你应该指定第三个参数递归 true 到 mkdir
-
您可能还想分享错误。据推测,您没有对
/home/bladimir的写入权限。检查该文件夹的权限,特别是写入权限。 -
你得到了
La carpeta fue creada,因为$Contraseña==1正在变为真实,它没有检查目录是否已创建..