How do I unzip a file (in any server OS) using PHP?

Josh Minzner

New member
I'm trying to create a PHP script which will update the web software. Right now, the update script uploads the ZIP file which contains the new version. I need this script to unzip the file and extract it to the directory above where the upgrade.php script is located (the same directory the zip is in.) Any clues. I tried this with no luck:

$zip = new ZipArchive;
if ($zip->open('../upgrade.zip') === TRUE) {
$zip->extractTo('../');
$zip->close();
echo 'ok';
} else {
echo 'failed';
}
 
Back
Top