Directory structure:
test
test/
test/test_zip.zip
test/test_zip
<span style="font-size:14px;"><?php header('Content-type:text/html;charset=utf-8'); $filename = 'test_zip.zip'; $path = './test_zip.zip'; $dir = 'test_zip'; if(!is_dir($dir)) { mkdir($dir, 0777, true);//Create a directory to save the decompressed content } if(file_exists($filename)) { $resource = zip_open($filename); while($zip = zip_read($resource)) { if(zip_entry_open($resource, $zip)) { $file_content = zip_entry_name($zip);//Get the file name, compress the mac into zip, decompression requires filtering the resource library to hide files $file_name = substr($file_content, strrpos($file_content, '/') +1); if(!is_dir($file_name) && $file_name) { $save_path = $dir .'/'. $file_name; if(file_exists($save_path)) { echo 'The file already exists in the folder "' . $file_name . '" <pre />'; }else { echo $file_name . '<pre />'; $file_size = zip_entry_filesize($zip); $file = zip_entry_read($zip, $file_size); file_put_contents($save_path, $file); zip_entry_close($zip); } } } } zip_close($resource); }</span>
The above example of decompressing the content of the php zip compressed package to the specified directory is all the content I share with you. I hope you can give you a reference and I hope you can support me more.