apache 使用 PHP FTP 获取文件的内容

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2341792/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 18:50:22  来源:igfitidea点击:

Getting the contents of a file with PHP FTP

phpapacheftp

提问by Meep3D

I am trying to get the contents of a file on a remote FTP server through PHP. Looking at all the docs though it doesn't appear possible to do this without first saving the transferred file to disk and then opening it.

我正在尝试通过 PHP 获取远程 FTP 服务器上的文件内容。查看所有文档,尽管如果不首先将传输的文件保存到磁盘然后打开它,似乎不可能做到这一点。

Is there any way of reading the file straight into a variable or buffer without having to save it to disk first?

有没有办法将文件直接读入变量或缓冲区,而不必先将其保存到磁盘?

Thanks.

谢谢。

回答by Gordon

file_get_contentscan use FTP stream wrapperstoo

file_get_contents可以使用FTP流包装

$content = file_get_contents('ftps://user:[email protected]/pub/file.txt');