来自 PHP 的 SFTP [英] SFTP from within PHP

查看:18
本文介绍了来自 PHP 的 SFTP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个网络应用程序,除其他事项外,该应用程序需要连接到 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?

推荐答案

是的,您可以使用 卷曲.要从 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.

顺便说一句.不要将 SFTP 与 FTPS 混淆.SFTP是SSH File Transfer Protocol,FTPS是FTP over SSL.

BTW. SFTP is not to be confused with FTPS. SFTP is SSH File Transfer Protocol, while FTPS is FTP over SSL.

这篇关于来自 PHP 的 SFTP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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