![](/img/trans.png)
[英]Recursive browse all server directories and list newest created files with php
[英]PHP Error - All Files or Directories created are 0
我最近正在编写一个注册脚本,并想在另一个名为“用户”的文件夹中创建一个文件夹。 不知何故,创建的文件夹位于根路径(php脚本所在的位置)中,并且应该写在该文件夹中的文件位于名为0的文件中。以下是代码:
if (!isset($_POST["method"])){
die("Error");
}
if (!isset($_POST["usernamefld"])){
die("Error");
}
if (!isset($_POST["passwordfld"])){
die("Error");
}
if ($_POST["method"] == "register"){
if (!isset($_POST["emailfld"])){
die("Error");
}
if(is_dir("./users/"+$_POST["usernamefld"])){
die("Taken");
}
mkdir("/users/"+$_POST["usernamefld"]);
echo "test";
}
文件夹“ 0”在创建时始终为空。
正如@u_mulder所说的,在PHP中,我们用“。”连接字符串和变量。 而不是“ +”符号。 基于此,这应该有助于解决您的特定问题。
if (!isset($_POST["method"])){
die("Error");
}
if (!isset($_POST["usernamefld"])){
die("Error");
}
if (!isset($_POST["passwordfld"])){
die("Error");
}
if ($_POST["method"] == "register"){
if (!isset($_POST["emailfld"])){
die("Error");
}
if(is_dir("./users/". $_POST["usernamefld"])){
die("Taken");
}
mkdir("/users/". $_POST["usernamefld"]);
echo "test";
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.