How to Unzip a file using PHP

02nd, January 2018 By

Today we will discuss how we unzip a file using php.By default Zip support in PHP is not enabled.You need to use the ZZIPlib library.Now we have using this simple function to unzip file in php.


$zip = new ZipArchive;

$result = $zip->open('');

if ($result === TRUE)




echo 'Extracted';

} else {

echo 'Not Extract';



Using this function we have extract the zip file in directory.Please check the permission of you directory.Here

$zip->open() :-               Open a ZIP file archive
$zip->extractTo() :-            Extract the archive contents
$zip->close() :-                Close a ZIP file archive

Using these functions we will Unzip a file in PHP.The Zip file mostly have more than one files in them so we have open ,extract and close the Zip file.Hope this will help you.

Leave a Reply

Your email address will not be published. Required fields are marked *