Forum Moderators: coopster

Message Too Old, No Replies

how do i copy a folder on the server

how do i copy a folder

         

MrGecko

2:15 am on Nov 19, 2006 (gmt 0)

10+ Year Member



how do i copy a folder on the server i'm useing this as my code and it dose not work
@copy("./2115125423/", "./".$Username."/");
i have the folder as 777

but it dose not work

please help me

eelixduppy

5:36 am on Nov 19, 2006 (gmt 0)



Copy is for copying files. To copy a whole directory, you must use your own function, or pre-made function. You can find many of these online. Here's one I just wrote up real quick. It has a lot of limitations, but it's just to give you the basic idea:

$dir = "directory/to/copy";
$dest = "destination/of/doom";
if(!is_dir($dest)) {
mkdir($dest);
}
foreach(scandir($dir) as $file) {
if($file!= '.' && $file!= '..') {
copy($dir.'/'.$file,$dest.'/'.$file);
}
}

Something like that. Obviously if you have a directory within the directory it won't work, but this is just an example ;)

Good luck!