Forum Moderators: coopster
i have a folder that is constantly updated with content, I need to create a script that will move the entire content of that folder (not the folder, just the files in it) to another destination folder. I just cannot seem to find a function in php to deal with the moving of files within the server itself.
thanx in advance
<?
$mydir = "/path/to/dir/";
$destdir = "/path/to/new/dir/";
$d = dir [ca.php.net]($mydir);
while($entry = $d->read()) {
if ($entry!= "." && $entry!= "..") {
$oldpath = $mydir . $entry;
$newpath = $destdir . $entry;
$success = copy [ca.php.net]($oldpath,$newpath);
if ($success) unlink($oldpath);
else die("There was an error copying $oldpath");
}
}
$d->close();
?>