How to Extract zip file on server

Mostly when you are transferring site from local server to the live server. You will upload the zip file of your project and then you will extract it on server.  But what if the hosting provider does not provide the zip extract functionality?

Recently while moving a site to , i faced same problem. I uploaded the zip file to server then tried to extract it , but wait, there was no option to extract the zip file. So finally i had to look for a script which extracts the zip file on server.

So here is the code snippet which lets you extract the zip file on your server. Following these steps in order to extract the zip.

1) Create a php file (unzip.php) and add following code  snippet in your file.

2) Specify the name of the zip file you want to extract in following line.

$out = $unzip->open('');
3) That’s it. Run the unzip.php file in your browser.
$unzip = new ZipArchive;
$out = $unzip->open('');
if ($out === TRUE) {
 echo 'File unzipped';
} else {
 echo 'Something went wrong?';
That’s it if “File unzipped” message is printed then this code worked perfectly for you.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s