简体   繁体   English

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

[英]How to move a php file from server to server

I am doing a Wordpress plugin that once you activate the plugin I want to copy some templates from a external repo(server) to the downloads folder in the current wordpress instance. 我正在做一个Wordpress插件,一旦您激活了插件,我想将一些模板从外部存储库(服务器)复制到当前wordpress实例中的downloads文件夹。

What I have done so far is this which works fine but the problem is that is trying to execute the php code functions inside, I am getting this erro fomr the error log : 到目前为止,我已经完成了这个工作,但是问题是尝试在其中执行php代码功能,我得到了这个错误日志:

[26-Sep-2014 00:11:47 America/Chicago] PHP Fatal error: Call to undefined function get_the_title() in /home/german/public_html/wp-content/uploads/template/squeeze-land.php on line 21 [2014年9月26日00:11:47美国/芝加哥] PHP致命错误:在第21行的/home/german/public_html/wp-content/uploads/template/squeeze-land.php中调用未定义的函数get_the_title()

So is trying to execute the get_the_titel() function 所以正在尝试执行get_the_titel()函数

I'd like to move a file to a target folder in another server. 我想将文件移到另一台服务器的目标文件夹中。 thank you. 谢谢。

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!';
}

Why don't you use "CURL" to copy the templates from other server to your server... This will help you more... 为什么不使用“ CURL”将模板从其他服务器复制到您的服务器...这将为您提供更多帮助...

Hope so this link will help you as well.. 希望如此,该链接也会对您有所帮助。

How to send file data via curl to another server in $_FILES 如何通过curl将文件数据发送到$ _FILES中的另一台服务器

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM