View Full Version : Copy a directory with PHP
Dalziel
05-08-2003, 01:35 PM
Is there any way to get PHP to make a copy of a directory and all the files in it with a different name, e.g. make a PHP script that created a directory called files2 which was simply a clone of files1.
Weirdan
05-08-2003, 02:53 PM
Something like this:
function copydir($source,$destination)
{
mkdir($destination);
if ($dir = @opendir()) {
while (($file = readdir($dir))!==false) {
copy($file,"$destination/$file");
}
closedir($dir);
}
}
Dalziel
05-09-2003, 11:07 PM
So $destination is the destination directory, $source is the original, what is $dir?
Weirdan
05-12-2003, 02:09 PM
$dir is directory handle, returned by opendir.
http://www.php.net/manual/en/function.opendir.php
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.