调用未定义的方法 Net_SSH2::put()
Call to undefined method Net_SSH2::put()
我使用的是 PHP_SSH2 版本 1.1.2(和 phpseclib 版本 1.0.11),在尝试上传文件时,我收到此错误:
PHP Fatal error: Uncaught error: Call to undefined method 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 操作。
我使用的是 PHP_SSH2 版本 1.1.2(和 phpseclib 版本 1.0.11),在尝试上传文件时,我收到此错误:
PHP Fatal error: Uncaught error: Call to undefined method 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 操作。