PHP复制问题

时间:2012-02-25 21:49:13

标签: php wordpress

我正在尝试将Wordpress内部的Plugin目录中的文件复制到Wordpress安装的根目录。这是我的代码:

$pluginfile = 'http://www.richmindonline.com/testenvironment/wp-content/plugins/malware
finder/process.php'; 

$urldest = 'http://www.richmindonline.com/testenvironment/process.php'; 

function copy(){  
global $pluginfile; global $urldest; 
copy($pluginfile,$urldest); } 
?>

我遇到了一些语法问题,因为它根本不起作用。

我也听说过我可能需要权限来执行此操作。我是如何实现这一目标的具体/通用示例?

提前谢谢。

1 个答案:

答案 0 :(得分:0)

您不能在您的情况下使用URL,只能使用服务器文件系统中文件的路径。一般来说它应该是这样的(我没有说它会起作用 - 一切都取决于文件的位置和所做的更改,例如,mod_rewrite):

$pluginfile = $_SERVER['DOCUMENT_ROOT'] . 
      '/testenvironment/wp-content/plugins/malwarefinder/process.php'; 

$urldest = $_SERVER['DOCUMENT_ROOT'] . '/testenvironment/process.php'; 

copy($pluginfile, $urldest);

不要将您的功能命名为内置功能。