UnZIP a file using PHP and ZipArchive

July 17th, 2012 by Alex Leave a reply »

I won’t say much – this really helps when there’s no adequate hosting panel:

$zip = new ZipArchive;
if ($zip->open('archive.zip') === TRUE) {
    echo 'ok';
} else {
    echo 'failed';

You will probably need to chown the folder after you unzip (unzipping may result in making apache the owner of the extracted files), just use the following command and replace admin:admin with your main user UID and GID:

chown -R rootfolder admin:admin

Comments are closed.