2011-01-11 60 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脚本可以处理这种情况。)