On my old VPS I was using the following code to copy the files and directories within a directory to a new directory that was created after the user submitted their form.
hmm. as that's complicated ))
function mkdir_recursive( $dir ){
$prev = dirname($dir);
if( ! file_exists($prev))
{
mkdir_recursive($prev);
}
if( ! file_exists($dir))
{
mkdir($dir);
}
}
...
foreach( $files as $file){
mkdir_recursive( dirname( $dir_d . $file));
copy( $dir_s . $file, $dir_d . $file);
}
$file
- somthing like that www/folder/ahah/file.txt