Ok i'm using those 2 simple functions to copy an entire directory:
function cp($wf, $wto){ // it moves $wf to $wto
if (!file_exists($wto)){
mkdir($wto,0777);
}
$arr=ls_a($wf);
foreach ($arr as $fn){
if($fn){
$fl="$wf/$fn";
$flto="$wto/$fn";
if(is_dir($fl)) cp($fl,$flto);
else copy($fl,$flto);
echo "$fl to $flto<br>";
}
}
}
///////////////////////////////////////////////////
/// ls_a function////////////////////////
// This function lists a directory.
// ANd is needed for the cp function.
function ls_a($wh){
if ($handle = opendir($wh)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." ) {
if(!$files) $files="$file";
else $files="$file\n$files";
}
}
closedir($handle);
}
$arr=explode("\n",$files);
return $arr;
}
Everything's working, and the directory is copied, the problem is that I don't have any permissions on the copied files after the copy is done....I can't rename/delete or even CHMOD them..(not only in php, but via FTP also) so now i'm stuck with the copied files on my server and there's nothing I can do... I tried on 2 different servers and got the same result...!