How to unzip files via an FTP connection?
I have connected to my remote server via FTP and I got a directory listing. I have few zip files in the list.
Is it possible to unzip the file (Ex: test.zip)?. If yes, what is the command?
Solution 1:
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.
Solution 2:
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.