Skip to content

Instantly share code, notes, and snippets.

@Rbn3D
Forked from trajche/unzip.php
Last active July 8, 2016 07:30
Show Gist options
  • Save Rbn3D/3c110fc40d5b69c03602c5288c1fa51b to your computer and use it in GitHub Desktop.
Save Rbn3D/3c110fc40d5b69c03602c5288c1fa51b to your computer and use it in GitHub Desktop.
Unzip a file outside web root (upper folder)
<?php
$unzip = new ZipArchive;
$out = $unzip->open('file-name.zip');
if ($out === TRUE) {
$unzip->extractTo(realpath(getcwd() . '/../'));
$unzip->close();
echo 'File unzipped to '.realpath(getcwd() . '/../');
} else {
echo 'Something went wrong?';
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment