我不太清楚如何从我拥有的示例目录中添加文件。我将感激你的帮助。当用户输入他们的用户名时,我已经成功地创建了一个新目录,但是目录的内容是空的。
编辑:我已经创建了所需的目录结构,只需要包括/复制我在样本模板中的页面。
<?php
$fileName = "/associate/sample/";
$Name = $_POST['name'];
$thisdir = getcwd();
$folderPath = $thisdir . '/' . $Name;
mkdir($folderPath);
chmod($folderPath, 0777);
file_put_contents (realpath("$fileName"), associate/$Name);
?>
你很接近,只是做得不对。把这个看一遍,然后和你刚才的比较一下,看看我做得有什么不同
$folder = "/associate/";
$name = 'Joshua';
$thisdir = getcwd();
$folderPath = $thisdir . $folder . $name;
$filename = $name.'.file';
if(!file_exists($folderPath)){
mkdir($folderPath);
chmod($folderPath,0777);
}
$textToWrite = 'this is some text';
file_put_contents(realpath($folderPath).'/'.$filename, $textToWrite);