How to unzip a zip file in python

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

Sample Python

import zipfile
myZip = zipfile.ZipFile('myArchive.zip','r')
for zipContentFile in myZip.namelist():
    data = myZip.read(zipContentFile)
    file = open(zipContentFile, 'w+b')
    file.write(data)
    file.close()

for more informations see Work with ZIP archives¶

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';
}