PHP Decompression zip file function, the source code is short, need to use zziplib Library extension, before using please confirm that the extension has been opened.
?
/**********************
* @file-path to zip file need to extract the path
* @destination-destination directory for unzipped Fi Les the path that is stored after the
*@ needs to use Zziplib Library, please confirm that the extension has opened
/function Unzip_file ($file, $destination) {
// Instantiate object
$zip = new ziparchive ();
Open the Zip document, if the open failure returns the prompt if
($zip->open ($file)!== TRUE) {
die ("could not open archive");
Extract the compressed file into the specified directory
$zip->extractto ($destination);
Close the zip document
$zip->close ();
Echo ' Archive extracted to directory ';
Test execution
//unzip_file ("Func.zip", "Jieya");
? >
This is the PHP extract zip file function code, I hope to help you learn.