[英]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.