Hello Reader's!, If you have a zip file and you need to execute unzip the file using PHP, Then you can use the PHP liberary code below:-
// Lets say you have zip file in the same folder of php file.
$file = 'file.zip';
// get the absolute path to $file
$path = pathinfo(realpath($file), PATHINFO_DIRNAME);
$zip = new ZipArchive;
$res = $zip->open($file);
if ($res === TRUE) {
// extract it to the path we determined above
$zip->extractTo($path);
$zip->close();
echo "Your file is now unziped! $file extracted to $path";
} else {
echo "Error! fail to open file: $file";
}
0 Comment(s)