Forum Moderators: coopster

Message Too Old, No Replies

Copy Dir sub-dir and files

         

henry0

7:31 pm on Mar 30, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



As is I am not generating errors
but does not work!0n PHP5 and Apache2-

<?php
//error_reporting (E_ALL);

$dirsource="../tpl_for_dupli/calendar";
$dirdest="../chamber_members/calendar";

function COPY_RECURSIVE_DIRS($dirsource, $dirdest)
{
if(is_dir($dirsource))$dir_handle=opendir($dirsource);
mkdir($dirdest."/".$dirsource, 0750);
while($file=readdir($dir_handle))
{
if($file!="." && $file!="..")
{
if(!is_dir($dirsource."/".$file)) copy ($dirsource."/".$file, $dirdest."/".$dirsource."/".$file);
else COPY_RECURSIVE_DIRS($dirsource."/".$file, $dirdest);
}
}
closedir($dir_handle); return true;

}

thank you

ergophobe

5:38 pm on Apr 1, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



What's not working?

Your file paths might have some problems. For example

mkdir($dirdest."/".$dirsource, 0750);

is the same as

mkdir("../tpl_for_dupli/calendar/../chamber_members/calendar", 0750);

which is really

mkdir("../tpl_for_dupli/chamber_members/calendar", 0750);

Is that what you want? I think I would use absolute path names if possible.

henry0

6:26 pm on Apr 1, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks
I will try using using an absolute path

My problem is that I cannot find an error
just results in a blank page

jatar_k

11:43 pm on Apr 1, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



>> My problem is that I cannot find an error

well, that's because there is no output. echo some vars so you can watch it loop through the dirs and find out what part of the function is dying