Reputation: 87
I'm using Phpseclib to retrieve files from remote server. Everything works fine but when I tried to zip a folder to download. The zip file I created using code below remain empty. I'm out of idea how to make it works. Is there something wrong in my code?
$sftp = new Net_SFTP($host);
if (!$sftp->login($user, $password)) {
exit('login failed');
}
$sftp->mkdir($zipfolder);
$sftp->put($zipfolder.'/'.$file, $sftp->get($file) );
$sftp->enablePTY();
$sftp->exec('cd '.$filepath.' && zip '.$zipfilename.' '.$zipfolder);
Upvotes: 0
Views: 1025
Reputation: 840
To ZIP directory you should write:
$sftp->exec('cd '.$filepath.' && zip -r '.$zipfilename.' '.$zipfolder);
Upvotes: 1