Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/289.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP复制函数不工作_Php_Html_File_Copy - Fatal编程技术网

PHP复制函数不工作

PHP复制函数不工作,php,html,file,copy,Php,Html,File,Copy,您好,我的复制功能在我的服务器上不工作。请任何人帮助解决它的问题 谢谢我相信运行php脚本的用户没有足够的权限在该文件夹中写入 在终端运行中,您需要为该用户提供文件夹: $filename = "../literature/apolloseries1700263589.pdf"; $newfilename = "../literature/new_apolloseries1700263589.pdf"; if (file_exists($filename)) { // This Work

您好,我的复制功能在我的服务器上不工作。请任何人帮助解决它的问题


谢谢

我相信运行php脚本的用户没有足够的权限在该文件夹中写入

在终端运行中,您需要为该用户提供文件夹:

$filename =  "../literature/apolloseries1700263589.pdf";
$newfilename = "../literature/new_apolloseries1700263589.pdf";
if (file_exists($filename)) { // This Work 
        if(copy($filename, $newfilename)) { // This Not Working  
            echo "Copy Success";
        } else { 
            echo "Copy Failed";
        }

     }

[用户]作为运行php脚本(通常是apache或www数据)的用户,您可以在终端中使用:
ps aux
并使用httpd检查该行,或者apache/apache2…

您有任何错误,请检查您的php中是否有allow\u url\u fopen=on。如果您试图在第525行取消引用空指针。是的allow\u url\u fopen为on…没有任何错误,它显示的只是显示副本失败,您可能没有在文献文件夹中写入的权限。
chown [user] ../litterature