I'm using PHP_SSH2 version 1.1.2 (and phpseclib version 1.0.11) and when trying to upload files, I get this error:
PHP Fatal error: Uncaught error: Call to undefined method Net_SSH2::put()
Here is the code I'm using:
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!");
I can connect to the server okay (so login()
works), but put()
doesn't?
Net_SSH2 does not have a put method. You'd need to use Net_SFTP to perform SFTP actions on the SSH server.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.