Pages

Wednesday, October 15, 2014

PHP unzip file code

$oldPath =  $_SERVER['DOCUMENT_ROOT'] . $_SERVER['REQUEST_URI'];
$path = str_replace("unzip.php","",$oldPath);
echo $path;

$zip = new ZipArchive;
$res = $zip->open('dadinfo.zip');
if ($res === TRUE) {
  $zip->extractTo($path);
  $zip->close();
  echo 'woot!';
} else {
  echo 'doh!';
}
?>