note 22627 added to function.copy

From: Date: Tue, 25 Jun 2002 16:57:41 +0000
Subject: note 22627 added to function.copy
Groups: php.notes 
Request: Send a blank email to php-notes+get-32181@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/') -- http://www.php.net/manual/en/function.copy.php http://master.php.net/manage/user-notes.php?action=edit+22627 http://master.php.net/manage/user-notes.php?action=delete+22627 http://master.php.net/manage/user-notes.php?action=reject+22627

« previous php.notes (#32181) next »