开发者

Editing a remote file on-the-fly with PHP

开发者 https://www.devze.com 2022-12-28 02:21 出处:网络
I have a requirement to edit a remote text file on-the-开发者_运维问答fly, the content of which currently stands at ~1Mb.

I have a requirement to edit a remote text file on-the-开发者_运维问答fly, the content of which currently stands at ~1Mb.

I have tried a couple of approaches and both seem to be clunky or hog memory which I can't rely on.

Thinking out logically what I'm trying to achieve is:

  1. FTP to a remote server.
  2. Download a copy of the file for backup purposes and store it somewhere locally.
  3. Open the remote file and add the necessary lines required.
  4. Remove lines from the remote file as per an array of un-required data generated from the local server.

Is this possible?

I've managed to code steps 1 and 2 but I'm having difficult with 3 and 4. The way I'm doing it now is to use fgets and return the whole string. Really, I don't want to do this as it involves manipulating and re-generating the whole string (and it's large) and then re-inserting it in between two markers in the remote file.

Is there no way of manipulating the lines of text in the file on-the-fly?


To the best of my knowledge you cannot do 3 and 4 via FTP. It does not allow manipulation of remote files, its for file transferring only.

0

精彩评论

暂无评论...
验证码 换一张
取 消