SFTP从PHP [英] SFTP from within PHP
问题描述
我正在建立一个网络应用程序,除了其他功能,还需要连接到FTP服务器以下载或上传文件。应用程序是用PHP编写的,并且托管在Linux服务器上。
I'm in the process of building an web app that will, besides other things, need to connect to a FTP server to download or upload files. The application is written in PHP and it's hosted on a Linux server.
我想知道的是,是否也可以提供对SFTP服务器的支持,在Google上进行一些快速搜索后,似乎并不是那么简单。
What I was wondering is whether or not it would be possible to also provide support for SFTP servers, but after some quick searches on Google it seems that this is not all that simple.
所以,问题是:从PHP中使用SFTP的最好方法是什么?是否有一个类,也可以为FTP和SFTP提供支持,以便可以使用相同的功能?
So, the question is: What would be the best way to use SFTP from within PHP? Is there a class that could also provide support for FTP as well as SFTP so that same functions could be used for both?
提前感谢您的时间,
titel
Thank you in advance for your time, titel
推荐答案
是的,您可以使用 cURL 。要从FTP切换到SFTP,您只需将协议选项形式 CURLPROTO_FTP
更改为 CURLPROTO_SFTP
。
Yes, you can do that with cURL. To switch from FTP to SFTP all you have to do is to change protocol option form CURLPROTO_FTP
to CURLPROTO_SFTP
.
cURL支持以下协议:HTTP,HTTPS,FTP,FTPS,SCP,SFTP,TELNET,LDAP,LDAPS,DICT,FILE,TFTP。
cURL supports following protocols: HTTP, HTTPS , FTP, FTPS, SCP, SFTP, TELNET, LDAP, LDAPS, DICT, FILE, TFTP.
BTW。 SFTP不要与FTPS混淆。 SFTP是SSH文件传输协议,而FTPS是通过SSL的FTP。
BTW. SFTP is not to be confused with FTPS. SFTP is SSH File Transfer Protocol, while FTPS is FTP over SSL.
这篇关于SFTP从PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!