0

I want to extract a zip file which is on another server. Is it possible using FTP credentials?

$dest = 'abc.zip';
$source = 'abc.zip';
$ftp = ftp_connect("ftp.example.com");
ftp_login($ftp, "username", "password");
ftp_put($ftp, $dest, $source, FTP_BINARY); 
ftp_close($ftp);
  • Through this code, your local `abc.zip` will get uploaded to your FTP location. PHP uses `ZIPArchive` class that contains an `extract` method. I don't think so it's possible to remotely extract a file on FTP using this class. `ZIPArchive`'s `open` method does not as of yet support stream wrappers (https://bugs.php.net/bug.php?id=68621). You have to download abc.zip locally and then extract it. – verisimilitude Oct 19 '19 at 13:53
  • Yes I'm trying with Ziparchive class, but it is not working on remote server. – Dattaraj Mahajan Oct 19 '19 at 14:17
  • Please re-read my comment. I said it may not be possible to use ZIPArchive class because it does not support stream wrappers as of yet. Read here to understand the concept of a stream wrapper => https://www.php.net/manual/en/wrappers.php – verisimilitude Oct 20 '19 at 15:06

0 Answers0