PHP – Unzip an uploaded file using php

If you dont have shell access to your server and need to unzip a file on your php server you can use the script below:

     $zip = new ZipArchive;
     $res = $zip->open(’’);
     if ($res === TRUE) {
         echo ‘ok’;
     } else {
         echo ‘failed’;

Basically it extracts the zip file into the directory you specify… make sure the directory you want to extract it to has write permissions. More info on this script is available on the php website One issue I ran into with this script was that I could not modify the files via my ftp program as they did not have permission set for this.



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