note 22627 deleted from function.copy by alindeman
| From: | alindeman@php.net | Date: | Fri, 09 May 2003 22:17:17 +0000 |
| Subject: | note 22627 deleted from function.copy by alindeman | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-47799@lists.php.net to get a copy of this message | ||
SIMPLE IMPROVEMENT:
function rec_copy ($from_path, $to_path) {
$this_path = getcwd();
if(!is_dir($to_path)){
mkdir($to_path, 0777);
}
if (is_dir($from_path)) {
chdir($from_path);
$handle=opendir('.');
while (($file = readdir($handle))!==false) {
if (($file != ".") && ($file != "..")) {
if (is_dir($file)) {
chdir($this_path);
rec_copy ($from_path.$file."/",
$to_path.$file."/");
chdir($this_path);
chdir($from_path);
}
if (is_file($file)){
chdir($this_path);
copy($from_path.$file, $to_path.$file);
chdir($from_path);
}
}
}
closedir($handle);
}
}
from_path & to_path are both relative to the php file! (eg: 'images/')