如何将php文件从服务器移动到服务器

如何将php文件从服务器移动到服务器,php,wordpress,Php,Wordpress,我正在做一个Wordpress插件,一旦你激活了我想要的插件 从外部回购(服务器)复制一些模板 到当前wordpress实例中的下载文件夹 到目前为止,我所做的是这项工作很好,但是 问题是试图执行里面的php代码函数, 我从错误日志中得到了以下错误: [26-Sep-2014 00:11:47 America/Chicago]PHP致命错误:在第21行的/home/german/public\u html/wp content/uploads/template/squeak-land.PHP中调

我正在做一个Wordpress插件,一旦你激活了我想要的插件 从外部回购(服务器)复制一些模板 到当前wordpress实例中的下载文件夹

到目前为止,我所做的是这项工作很好,但是 问题是试图执行里面的php代码函数, 我从错误日志中得到了以下错误:

[26-Sep-2014 00:11:47 America/Chicago]PHP致命错误:在第21行的/home/german/public\u html/wp content/uploads/template/squeak-land.PHP中调用未定义函数get_title()

因此,正在尝试执行
get\u titel()
函数

我想将文件移动到另一台服务器中的目标文件夹。 多谢各位

函数getTemplates(){ $url='1http://domain.com/wp-content/uploads/template/squeeze-land.php'; $newFile=$_SERVER['DOCUMENT_ROOT']./wp content/uploads/template/testing.php'; 设置_time_limit(0);//最大执行时间不限 $path=$newFile; $url=$url; $newfname=$path; echo“开始下载!
”; $file=fopen($url,“rb”); 如果($file){ $newf=fopen($newfname,“wb”); 如果($newf) 而(!feof($file)){ fwrite($newf,fread($file,1024*8),1024*8); 回显“已写入1 MB文件块!
”; } } 如果($file){ fclose($文件); } 如果($newf){ fclose($newf); } echo‘完成了!’; } 为什么不使用“CURL”将模板从其他服务器复制到您的服务器上。。。这将帮助你更多

希望此链接也能对您有所帮助


Hi,我尝试了CURl,我遇到了同样的问题,就是执行php文件。到目前为止,我不得不将文件扩展名改为.txt,这样就不会解释php。但这仍然只是一个临时解决方案。文件是公开的吗?你能用浏览器得到它吗?
function getTemplates(){

       $url = 'http://domain.com/wp-content/uploads/template/squeeze-land.php';
       $newFile = $_SERVER['DOCUMENT_ROOT'].'/wp-content/uploads/template/testing.php';

        set_time_limit(0); //Unlimited max execution time

        $path = $newFile;
        $url = $url;
        $newfname = $path;
        echo 'Starting Download!<br>';
        $file = fopen ($url, "rb");
        if($file) {
            $newf = fopen ($newfname, "wb");
            if($newf)
                while(!feof($file)) {
                    fwrite($newf, fread($file, 1024 * 8 ), 1024 * 8 );
                    echo '1 MB File Chunk Written!<br>';
                }
        }
        if($file) {
            fclose($file);
        }
        if($newf) {
            fclose($newf);
        }
        echo 'Finished!';
}