codingtcher.com
Theme Night
Home
Login

How to unzip a file using php

Home » Tutorial Post » How to unzip a file using php
function unzip($file,$extract){
if(class_exists('ZipArchive')){
    $zip = new ZipArchive;
    if ($zip->open($file) === TRUE && is_file($file)){
        $zip->extractTo($extract);
        $zip->close();
    }
  }
else{
    return false;
}
}

$zipfile = $_SERVER["DOCUMENT_ROOT"].'/new.zip';
$extractdir = $_SERVER["DOCUMENT_ROOT"].'/dir';
unzip($zipfile,$extractdir);

Related Post