[英]Connecting PHP to SFTP using phpseclib
I need to connect to a SFTP server to upload files using PHP (PHP version: 5.3.13). 我需要连接到SFTP服务器以使用PHP(PHP版本:5.3.13)上传文件。
I'm trying to use phpseclib but I get the following error: 我正在尝试使用phpseclib,但出现以下错误:
Notice: No compatible server to client encryption algorithms found in [...]\\phpseclib1.0.2\\Net\\SSH2.php on line 1375 Login Failed 注意:在第1375行,在[\\] \\ phpseclib1.0.2 \\ Net \\ SSH2.php中找不到兼容的服务器到客户端加密算法
The code I'm using is: 我使用的代码是:
include(CfgPath .'/phpseclib1.0.2/Net/SFTP.php');
include(CfgPath .'/phpseclib1.0.2/Crypt/Random.php');
$port = 22;
$sftp = new Net_SFTP($host, $port);
if (!$sftp->login($user, $pass)) {
exit('Login Failed');
} else { echo 'Sucess'; }
Any idea of what might be causing this problem and how to solve it? 是否知道可能会导致此问题以及如何解决的任何想法? Thank you! 谢谢!
Adding this at the top set_include_path(CfgPath .'/phpseclib1.0.2/'); 将其添加到顶部set_include_path(CfgPath。'/ phpseclib1.0.2 /'); like Denis Alimov suggested solved it. 就像Denis Alimov建议的那样解决了它。 Thank you! 谢谢!
I added this line above all the line 我在所有行上方添加了此行
set_include_path(get_include_path() . PATH_SEPARATOR . 'phpseclib1.0.2');
The PHP file is looking for a plugin which can be found at \\xampp\\php\\PEAR
for client encryption. PHP文件正在寻找可以在\\xampp\\php\\PEAR
用于客户端加密的插件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.