Forum Moderators: coopster
Code is :
#####################################
function copy_dir($source, $destination) {
if (is_file($source)) {
$perm = fileperms($source);
copy($source, $destination);
chmod($destination, $perm);
}
if (is_dir($source)) {
mkdir($destination, 0777);
$dir_handle = opendir($source);
while ($files = readdir($dir_handle)) if( $files!= "." && $files!= "..") $file_array[] = $files;
closedir($dir_handle);
}
for($i=0; $i<count($file_array); $i++) {
$file = $file_array[$i];
if ($destination!= "$source/$file") copy_dir("$source/$file", "$destination/$file");
}
}
##############################
Thanks
That codes looks like the *copy directory* part. Are you saying you are creating the source directory via a script and then trying to delete the directory with your FTP client? But you are unsuccessful? That's because the user that created the directory (and subdirectories) is different than the user in your FTP client program.
Do you have shell access? You can login and have a look at the owner/group authorites and you will see they are more than likely different than the userid you use to login via FTP.
I'm not sure which HTTP Server you are using, but PHP (by default) runs as whatever Apache is running as.
I understand the problem after reading your reply. I made a little change in the code :
############
$oldmask = umask(0);
mkdir($destination, 0777);
umask($oldmask);
############
Now everything is fine. I don't know why script was not assigning permission to directory without using "umask". Anyhow it was great help.
Another thing, is there any way to apply the same permission from one file/dir to otherone file/dir.
Thanks
Nadeem