2011-01-11 58 views
0

有人可以告訴我爲什麼這個功能根本不復制文件?PHP的「複製」不起作用

$pluginfile = get_bloginfo('template_url') . '/wp-content/plugins/supersqueeze/supersqueeze.php'; 

$urlparts = get_bloginfo('template_url'); 
$homeurl = home_url(); 
$urlstrip = str_replace($homeurl, '..', $urlparts); 
$urldest = $urlstrip . '/supersqueeze.php'; 

function copyemz(){ 
global $pluginfile; global $urldest; 
if([email protected]($pluginfile,$urldest)) { 
     $errors= error_get_last(); 

    } 
} 

該文件是從/public_html/wp-admin/plugins.php

運行我需要它的文件在($ pluginfile)/public_html/wp-content/plugins/supersqueeze/supersqueeze.php

到($ urldest)/public_html/wp-content/themes/[active wordpress theme]複製 - 當然替換[活躍wordpress主題]與主題的目錄。

+1

`$ errors`說什麼? – ajreal 2011-01-11 06:25:19

+3

刪除@並告訴我們你得到了什麼錯誤 – meze 2011-01-11 06:25:45

回答

1

您需要確保您擁有對/public_html/wp-content/themes/[active wordpress theme]的寫入權限以及任何其他可能覆蓋的文件。

1

因此,copy()的第二個參數必須是本地文件。確保它也是一個可寫目的地(chmod),就像webbiedave說的那樣。

$desturl = "./supersqueeze.php"; 

原因是雙重的。 PHP的HTTP流封裝不支持POSTing或PUTing文件,這是寫入操作需要的。其次,你的網絡服務器可能不會支持HTTP PUT。 (雖然一個小的requesthandler腳本可以處理這種情況。)