因此,我使用复制功能复制文件夹及其所有内容。问题是,我在调用函数时遇到以下错误:
Warning: copy(//index.php): failed to open stream: Permission denied in /var/www/localhost/public_html/cms/app/functions.php on line 21
Warning: copy(//page.php): failed to open stream: Permission denied in /var/www/localhost/public_html/cms/app/functions.php on line 21
/* More of the same warnings below */
复制功能:
function recurse_copy($src,$dst) {
$dir = opendir($src);
@mkdir($dst);
while(false !== ( $file = readdir($dir)) ) {
if (( $file != '.' ) && ( $file != '..' )) {
if ( is_dir($src . '/' . $file) ) {
recurse_copy($src . '/' . $file,$dst . '/' . $file);
}
else {
copy($src . '/' . $file,$dst . '/' . $file);
}
}
}
closedir($dir);
}
调用该函数:
switch ($id) {
case 1:
copyfolder("install/default","/");
break;
default:
header('Location: /cms/admin/templates');
break;
}
我尝试复制的文件夹(install/default
)具有rwxrwxrwx
(077)权限。
我还尝试将Apache添加到有权访问/var/www/
文件夹的用户组,但没有运气。