note 14855 deleted from function.copy by cece
| From: | cece@php.net | Date: | Tue, 19 Aug 2003 12:36:49 +0000 |
| Subject: | note 14855 deleted from function.copy by cece | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-54660@lists.php.net to get a copy of this message | ||
Note Submitter: junk@steti.com
----
Here is a sample function for copy a directory, and ALL subdirectories.
-----
function rec_copy ($from_path, $to_path) {
mkdir($to_path, 0777);
$this_path = getcwd();
if (is_dir($from_path)) {
chdir($from_path);
$handle=opendir('.');
while (($file = readdir($handle))!==false) {
if (($file != ".") && ($file != "..")) {
if (is_dir($file)) {
rec_copy ($from_path.$file."/", $to_path.$file."/");
chdir($from_path);
}
if (is_file($file)){
copy($from_path.$file, $to_path.$file);
}
}
}
closedir($handle);
}
}