我之前问过类似的问题,但之前不知道怎么问。下面我根据从注册表单中获取的用户名创建了一个新目录。我只需要包含复制到刚刚创建的新目录的模板文件。我得到的结果是将文件包含在上一级的目录中。新目录是使用用户名创建的,但其目录中不包含模板文件。我为此花了几个小时,所以我不必再打扰你们了。我究竟做错了什么?
$folder = DIRECTORY_SEPARATOR; // adds the forward slash
$name = $user->username; // included from a login script I purchased
$thisdir = "../associate"; // desired directory
$folderPath = $thisdir . $folder . $name;
$file = copy('../associate/joshua/career.php', $folderPath.'.php'); // copy this file into new directory
if(!file_exists($folderPath)){
mkdir($folderPath);
chmod($folderPath,0777);
}
file_put_contents(realpath($folderPath) .'/'. $folderPath, $file);
});