I want to transfer all the images associated to that product from M1 to M2 using sftp. I can connect to M1 using sftp. But I am not getting how to transfer it.
Here is a code to connect with sftp –
//FTP Connection
public function connectFtp($host, $user, $password, $ssl=true, $passive=true){
return $connect = $this->sftp->open(
array(
'host' => $host,
'user' => $user,
'password' => $password,
'ssl' => $ssl,
'passive' => $passive
)
);
}
//Downlaod images from M1 and transfer to M2 temp folder
public function downloadImages($images){
//Connecting to M1
$connect = $this->connectFtp(SELF::M1_HOST, SELF::M1_USERNAME, SELF::M1_PASSWORD, SELF::M1_SSL, SELF::M1_PASSIVE);
if($connect){
/* Code to transfer */
}
}
How to achieve this file transfer? As per some project requirements, we don’t want to use any plugin.
2
Answers
Do you just want to transfer ALL the images from M1 to M2?
You can try to rsync the images across instead:
Working code for File transfer from SFTP server to Our Server.