PHP: 将文件从站点 A 复制到站点 B

PHP: Copy file from site A to site B

我的服务器有 30 个网站。 现在我想将文件从站点 A 复制到站点 B。

代码:

$sExternPath  = str_replace(strtolower(SITENAME), strtolower($aBoardInfo['name']), CORE_PATH_PRIVATE); 
$sNewLogo     = file_get_contents(CORE_PATH_PRIVATE.'users_upload/company_logos/'.$sFileName);
//Put it in the folder 
file_put_contents($sExternPath.$sFileName, $sNewLogo);

错误:

[20-Mar-2015 10:32:30] PHP Warning: file_put_contents() [function.file-put-contents]: open_basedir restriction in effect. File(/var/www/vhosts/SITEB.nl/private/logo.jpg) is not within the allowed path(s): (/var/www/vhosts/SITEA.nl/:/tmp/) in /var/www/vhosts/SITEA.nl/httpdocs/pages/login/script.php on line 1262

[20-Mar-2015 10:32:30] PHP Warning: file_put_contents(/var/www/vhosts/SITEB.nl/private/logo.jpg) [function.file-put-contents]: failed to open stream: Bewerking niet toegestaan in /var/www/vhosts/SITEA.nl/httpdocs/pages/login/script.php on line 1262

/var/www/vhosts/SITEB.nl 在 open_basedir 设置中设置的树之外 - 您需要编辑 php.ini 文件并将 open_basedir 设置更改为 '/var/www/vhosts/:/tmp/' 而不是 '/var/www/vhosts/SITEA.nl/:/tmp/' 或通过注释掉它来取消设置,然后重新启动 apache。

http://php.net/manual/en/ini.core.php#ini.open-basedir

When a script tries to access the filesystem, for example using include, or fopen(), the location of the file is checked. When the file is outside the specified directory-tree, PHP will refuse to access it. All symbolic links are resolved, so it's not possible to avoid this restriction with a symlink. If the file doesn't exist then the symlink couldn't be resolved and the filename is compared to (a resolved) open_basedir .