你可以使用ftp_put()或类似的东西将行追加到远程文件吗? [英] Can you append lines to a remote file using ftp_put() or something similar?

查看:297
本文介绍了你可以使用ftp_put()或类似的东西将行追加到远程文件吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是情况...我有两台服务器,服务器1和服务器2。
服务器1从服务器2下载csv文件,从服务器2中删除它,从中读取行并进行一些处理。 / p>

在处理时,可以重新创建或更改服务器2上的文件,添加更多行。
完成处理后,服务器1需要将文件上传回服务器2.



但是,ftp_put()将完全覆盖服务器2上的文件。我真正想要做的是追加到服务器2上的文件,而不是覆盖它。有没有办法做到这一点?

解决方案

Curl支持附加FTP:

  curl_setopt($ ch,CURLOPT_FTPAPPEND,TRUE); // APPEND FLAG 

这可能是您要查找的内容。您是否熟悉curl?



另一种选择是使用 ftp:// / ftps:// 流,因为他们允许附加PHP 5。请参阅 ftp://; ftps:// Docs 。可能更容易访问。


Here's the situation... I have two servers, server 1 and server 2. server 1 downloads a csv file from server 2, deletes it off server 2, reads lines from it and does some processing.

While it is processing, the file on server 2 can be re-created or changed, adding more lines. After it is done processing, server 1 needs to upload the file back to server 2.

However, ftp_put() will completely overwrite the file on server 2. What I really want to do is append to the file on server 2 and not overwrite it. Is there any way to do this?

解决方案

Curl support appending for FTP:

curl_setopt($ch, CURLOPT_FTPAPPEND, TRUE ); // APPEND FLAG

This might be what you're looking for. Are you familiar with curl?

The other option is to use ftp:// / ftps:// streams, since PHP 5 they allow appending. See ftp://; ftps:// Docs. Might be easier to access.

这篇关于你可以使用ftp_put()或类似的东西将行追加到远程文件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆