I have successfully connected SFTP in magento 2 by referring the below URL:
How to connect SFTP in magento 2
Now, I want to send a file to that server. In order to send a file, how can I proceed?
Could anyone please help me with this?
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityI have successfully connected SFTP in magento 2 by referring the below URL:
How to connect SFTP in magento 2
Now, I want to send a file to that server. In order to send a file, how can I proceed?
Could anyone please help me with this?
$serverInfo = [
'host' => "host",
'username' => "username",
'password' => "pwd",
];
// use construct injection sftp : \Magento\Framework\Filesystem\Io\Sftp
$this->sftp->open($serverInfo); //the serverinfo is server config
$this->sftp->cd($path);//the path is you will upload path
$this->sftp->write($filename, $source); // filename and string data or local file name
$this->sftp->close();