Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/244.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在PHP中使用FTP从另一台服务器读取文件_Php_Ftp - Fatal编程技术网

在PHP中使用FTP从另一台服务器读取文件

在PHP中使用FTP从另一台服务器读取文件,php,ftp,Php,Ftp,他告诉大家, 我正在尝试使用PHP中的FTP函数从FTP 1到FTP 2获取文件。我能够找到文件,并获得名单也从FTP 2。但我不知道如何将这些文件复制到FTP 1。这就是我达到的程度 $ftp_server = "********"; $ftp_user_name = "******"; $ftp_user_pass = "******"; $ftp_dir = "*********"; $mode = "list_xml_files"; $file_li

他告诉大家,

我正在尝试使用PHP中的FTP函数从FTP 1到FTP 2获取文件。我能够找到文件,并获得名单也从FTP 2。但我不知道如何将这些文件复制到FTP 1。这就是我达到的程度

$ftp_server    = "********";
$ftp_user_name = "******";
$ftp_user_pass = "******";
$ftp_dir       = "*********";
$mode          = "list_xml_files";

$file_list = ftp_list_xml_files ($ftp_server,$ftp_user_name,$ftp_user_pass,$ftp_dir,$mode,$file);

print_r($file_list);
die;
到目前为止,它工作得很好,下面是$file\u list的输出

Array ( [0] => orders01-04-2014.xml [1] => orders02-04-2014.xml )
现在我想把这两个XML放在FTP 1上。。。你知道我如何复制它们并将它们放在我的FTP 1上吗

谢谢

您也可以使用和来执行此操作

<?php
    file_put_contents($save_location, fopen($filename, 'r'));
?>

希望能有所帮助。

PHP有一个完整的FTP扩展,正如我提到的,我真的无法理解逻辑…连接后,我有文件列表,但如何连接到两个FTP以便在它们之间传递文件?我将您的代码放在其中,但我收到了与我之前收到的警告相同的警告和错误:fopen(orders01-04-2014.xml):无法打开流:在……中没有此类文件或目录。您必须提供完整的url才能使其正常工作。例如:fopen(“);
<?php
    foreach($file_list as $filename)
        file_put_contents($save_location, fopen($filename, 'r'));
?>
$location = "{$_SERVER['DOCUMENT_ROOT']}/files/downloads";