wwood_cc
wwood_cc

Reputation: 87

Not able to zip folder in remote server

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

Answers (1)

pronngo
pronngo

Reputation: 840

To ZIP directory you should write:

$sftp->exec('cd '.$filepath.' && zip -r '.$zipfilename.' '.$zipfolder);

Upvotes: 1

Related Questions