簡體   English   中英

如何將php文件從服務器移動到服務器

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

我正在做一個Wordpress插件,一旦您激活了插件,我想將一些模板從外部存儲庫(服務器)復制到當前wordpress實例中的downloads文件夾。

到目前為止,我已經完成了這個工作,但是問題是嘗試在其中執行php代碼功能,我得到了這個錯誤日志:

[2014年9月26日00:11:47美國/芝加哥] PHP致命錯誤:在第21行的/home/german/public_html/wp-content/uploads/template/squeeze-land.php中調用未定義的函數get_the_title()

所以正在嘗試執行get_the_titel()函數

我想將文件移到另一台服務器的目標文件夾中。 謝謝。

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

為什么不使用“ CURL”將模板從其他服務器復制到您的服務器...這將為您提供更多幫助...

希望如此,該鏈接也會對您有所幫助。

如何通過curl將文件數據發送到$ _FILES中的另一台服務器

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM