简体   繁体   English

将PHP文件从一台服务器复制到另一台服务器

[英]Copying PHP files from one server to another

I am trying to copy some files from one server to another using PHP. 我正在尝试使用PHP将某些文件从一台服务器复制到另一台服务器。 Its working perfectly for text and image files, however, if the file I try to copy is a PHP file itself it bombs and copies some funny data as though it was trying to execute the file. 它非常适合文本和图像文件,但是,如果我尝试复制的文件本身是PHP文件,则它会炸弹并复制一些有趣的数据,就像试图执行该文件一样。 Is there a special way to copy example.php from server A to server B? 有没有一种特殊的方法可以将example.php从服务器A复制到服务器B?

for($i = 0; $i < count($serverAFiles); $i++) 
{
  set_time_limit(1800);
  $serverAFiles[$i] = trim($serverAFiles[$i] );
  copy ($serverAFiles[$i] , $serverBFiles[$i]);
}

You can use FTP or ssh with the correct credentials of course. 当然,您可以使用FTP或ssh使用正确的凭据。 For ssh you can use shell_exec and for FTP there is an extension . 对于ssh,可以使用shell_exec ;对于FTP,可以使用扩展名 To copy the file that is executed, try to make a copy of the contents first and they sending it away. 要复制执行的文件,请尝试首先复制内容并将其发送出去。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM