How to unzip files via an FTP connection?

Little bit out of context answer but surely works. If you are running a Apache + php on that ftp directory then upload your zip file in that folder and create extractor.php:

$zip = new ZipArchive;
if ($zip->open('my_zip.zip') === TRUE) {
    $zip->extractTo('/path/to/my/zip');
    $zip->close();
    echo 'ok';
}

and then hit url eg: http://example.com/extractor.php bingo php will extract that zip for you.


It is not possible to unzip files over an FTP connection. FTP stands for "File Transfer Protocol", which was only designed to transfer and partly manage files on the remote end, but not to execute commands. To unpack an archive you'd have to execute a program like tar, bzip2 or similar, but that's not possible via a FTP connection.

You need another session which allows you to execute commands, like SSH. Or you unpack the archive on your machine and transfer the contents via FTP, which will be considerable slower if you have a large number of small files because of the overhead of FTP.


You can do it if you mount ftp resource using curlftpfs:

curlftpfs ftp://ftp.server.org/ /path/to/mountpoint

then

unzip /path/to/mount/test.zip