Corona SDK and other Game Development Tutorials
@gamebuilding

Unzipping files with php

Recently, I’ve had to unzip a file using php. The code below takes advantage of the ZipArchive class and will extract a zipped file to the current directory. Here’s how.

$zip = new ZipArchive;    

$res = $zip->open($filename);

if ($res === TRUE) {
	$zip->extractTo('./');
	$zip->close();
	echo 'Unzip was successful';
} else {
	echo 'Unzip was not successful';
}

If you want to change the location of the extracted files, change extractTo(”) to the directory it needs to go to.

Leave a Reply