note 31769 added to function.copy

From: Date: Fri, 02 May 2003 22:08:47 +0000
Subject: note 31769 added to function.copy
Groups: php.notes 
Request: Send a blank email to php-notes+get-47407@lists.php.net to get a copy of this message
File ownership (on unix probably 'nobody') didnt have anything todo with the error of not being able to edit the file and eventually uploading it via a 'proper' userid and ftp-browser. My problem and my work around to michael at zend dot com snippet was lying in the file permission and fixed in one simple line: chmod("$newname", 0777); following the snippet again in total: function my_copy($oldname, $newname) { if(is_file($oldname)){ $perms = fileperms($oldname); return copy($oldname, $newname) && chmod($newname, $perms); } else if(is_dir($oldname)){ my_dir_copy($oldname, $newname); } else{ die("Cannot copy file: $oldname (it's neither a file nor a directory)"); } } function my_dir_copy($oldname, $newname) { if(!is_dir($newname)){ mkdir($newname); chmod("$newname", 0777); } $dir = opendir($oldname); while($file = readdir($dir)){ if($file == "." || $file == ".."){ continue; } my_copy("$oldname/$file", "$newname/$file"); } closedir($dir); } ------------- simply worked better for me. (host all-inkl.com) -- http://www.php.net/manual/en/function.copy.php http://master.php.net/manage/user-notes.php?action=edit+31769 http://master.php.net/manage/user-notes.php?action=delete+31769 http://master.php.net/manage/user-notes.php?action=reject+31769

« previous php.notes (#47407) next »