note 31769 deleted from function.copy by aidan
| From: | aidan@php.net | Date: | Mon, 30 Aug 2004 07:04:04 +0000 |
| Subject: | note 31769 deleted from function.copy by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-75644@lists.php.net to get a copy of this message | ||
Note Submitter: bas at indust3 dot net
----
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:
<?php
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)