How to unzip a zip file in PHP

To unzip a zip file in PHP you can use the following snippet.

Sample PHP

function Unzip($filename, $destination){
	$zip = new ZipArchive() ;
	if ($zip->open($filename) !== TRUE) {
		die ('Could not open archive file');
	}
	$zip->extractTo($destination);
	$zip->close();
	echo 'Archive successfully extracted to directory';
}

Please Share us:
Please rate this snippet

3 thoughts on “How to unzip a zip file in PHP

Leave a Reply