-1

I can't quite figure out how to add files from a sample directory that I have. I would appreciate some help. I have successfully created a new directory when ever a user inputs their username, but the contents are empty.

Edit: I've created the desired directory structure, just need to include/copy over the pages that I have in the sample template.

<?php
     $fileName = "/associate/sample/";

    $Name = $_POST['name'];

    $thisdir = getcwd();

    $folderPath = $thisdir . '/' . $Name;

    mkdir($folderPath);

    chmod($folderPath, 0777);

    file_put_contents (realpath("$fileName"), associate/$Name);

    ?>
4

1 回答 1

2

你很接近,只是做得不太对。看看这个,和你必须做的比较,看看我做了什么不同的事情

$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);
于 2015-09-03T03:43:57.260 回答