0

Is it possible that php can create a new directory with certain files inside.

For example when the php code is activated it duplicates a folder in my server directory with it's own name?

I would very much appreciate if anyone could provide the start of the code I would need.

Tom

Tom Buxton
  • 65
  • 2
  • 9
  • possible duplicate of [Recursive Copy of Directory](http://stackoverflow.com/questions/5707806/recursive-copy-of-directory) – rjdown Jun 14 '15 at 16:43

1 Answers1

0

Try something like this:

if(!file_exists('folderName')) {
    mkdir('folderName', '0777', true);

    $path = realpath('folderName');
    $file = fopen($path . "/file1.txt", 'w') or die("Could not open the file");
}
tbraun89
  • 2,246
  • 3
  • 25
  • 44
rashidkhan
  • 462
  • 8
  • 24
  • I very new at php. So I can't read it. Can you explain to me what this code means. Could you possible tell me where the code is getting the source folder from and what it's naming it. ? – Tom Buxton Jun 14 '15 at 17:37
  • mkdir function creates the directory for you and you can name it anything. fopen function will try to open a file if it doesn't exist, it will create it. You better read these functions documentation on php.net. – rashidkhan Jun 14 '15 at 18:34