copy files in Server..................

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
madhu
Forum Commoner
Posts: 82
Joined: Fri Mar 03, 2006 9:34 am

copy files in Server..................

Post by madhu »

hi please reply to my problem As Soon As Posible................

problem:
----------
source directory:pdf/2006/05/16
target directory:test/2006/05/16

now problem is it is not copying from source directory to target directory.

i gave all permissions to all folders as 0777.

please see the code and reply what is the wrong in my code As Soon As Posible................


CODE:
-------
<?

ini_set("max_execution_time", 0);

chmod("test", 0777);
chmod("test/2006", 0777); //permissions
chmod("test/2006/05", 0777);
chmod("test/2006/05/16", 0777);


$page="20060516";
$sfilepath = "pdf";
$year = substr($page,0,4);
$month = substr($page,4,2);
$day = substr($page,6,2);
$dirpath = $sfilepath.'/'.$year.'/'.$month.'/'.$day; //source directory
$sourcedir = @opendir($dirpath);

$tfilepath="test";
$target=$tfilepath.'/'.$year.'/'.$month.'/'.$day; //target directory
$targetdir = @opendir($target);

while(!is_bool($filename = @readdir($sourcedir)))
{
if($filename != '.' && $filename != '..')
{
$sfile = $dirpath.'/'.$filename;
$tfile = $target.'/'.$filename;
@copy($sfile,$tfile); //copy from source to target
}
}
?>

Waiting for your valuable replies..............

Thanks and regards
madhu
Post Reply