[英]Call to undefined method Net_SSH2::put()
我使用的是PHP_SSH2版本1.1.2(和phpseclib版本1.0.11),当尝试上传文件时,出现以下错误:
PHP致命错误:未捕获错误:调用未定义的方法Net_SSH2 :: put()
这是我正在使用的代码:
require 'Net/SSH2.php';
define('NET_SSH2_LOGGING', NET_SSH2_LOG_COMPLEX);
$connection = new Net_SSH2($ftp_server);
if(!$connection->login($ftp_user_name, $ftp_user_pass)){
die("FTP connection has failed!\nAttempted to connect to $ftp_server for user $ftp_user_name");
}
$source_file = 'filename.txt';
$destination_file = $source_file;
$upload = $connection->put($destination_file, $source_file, NET_SFTP_LOCAL_FILE);
if (!$upload) die("FTP upload of $source_file has failed!");
我可以连接到服务器好(这样login()
可以工作),但是put()
不可以吗?
Net_SSH2没有put方法。 您需要使用Net_SFTP在SSH服务器上执行SFTP操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.