How to Unzip file with PHP in Server when you don’t have cPanel access

Well, I faced the same problem when I was trying to install WordPress in a Server where I don’t have cPanel access or any file manager that support some kind of feature. I had only FTP access to upload file and database access. And then start finding out the way How to Unzip file in Serer with PHP when you don’t have cPanel access. I found a great way whit I am going to share with you down below.

Some says following will be okay

system('unzip File.zip');

Where File.zip will be zipped file name this code should be in the same directory where your zip file is. Now it may work for some people but not for me. 🙁 and then found another way again that was not for me, code as below

<?php
$zip = new ZipArchive;
if ($zip->open('test.zip') === TRUE) {
 $zip->extractTo('/my/destination/dir/');
 $zip->close();
 echo 'ok';
} else {
 echo 'failed';
}
?>

PHP Unzipper script to unzip folder in server

and then I found a script from github by Andreas Tasch (ndeet) at https://github.com/ndeet/unzipper which is really simple and easy to use.

You just need to upload the unzipper.php into the same folder where you have some zip folder in your server. And then run the script from your browser and you will get a nice interface with Drop-down list of those zipped folder. And you will get an option to decide where you want to keep your unzipped files.

PHP Unzipper script to unzip folder in server
PHP Unzipper script to unzip folder in server

As like the above picture, if there is any zip file in your server (actually in the same folder where your script is ), it will show the list and from Archive Unzipper option, select your zip file and choose the part and then Unzip Archive. Now if the extraction path is empty, it will upzip into the same folder.

Now if you need to zip any server file, again it could be your solution as it has another feature called Archive Zipper. Now what are you waiting for? To get that script, go to https://github.com/ndeet/unzipper and use it.

Wish you all the best and will come up with new things.


Leave a Reply

Your email address will not be published. Required fields are marked *