Home>Article>Backend Development> How to decompress compressed package in php
php implements decompression of ZIP compressed files
First: You need to enable the configuration of php_aip.dll
".$i++." 此文件已被跳过,原因:文件过大, -> ".iconv("gb2312","utf-8",$file_name)." "; } } //关闭当前 zip_entry_close($dir_resource); } } //关闭压缩包 zip_close($resource); $endtime = explode(' ',microtime()); //解压结束的时间 $thistime = $endtime[0]+$endtime[1]-($starttime[0]+$starttime[1]); $thistime = round($thistime,3); //保留3为小数 echo "解压完毕!,本次解压花费:$thistime 秒。
"; } $size = get_zip_originalsize('../../textaa.zip','../../ffff/');
In the above method: $filename: file name, is the name of the file to be decompressed, including the path relative to the method, $path represents: decompress to (what directory, ending with / ).
The second method is: use the class that comes with pclzip. The first method was adopted during the project due to path problems
open('test.zip') === TRUE) {//中文文件名要使用ANSI编码的文件格式 $zip->extractTo('foldername');//提取全部文件 //$zip->extractTo('/my/destination/dir/', array('pear_item.gif', 'testfromfile.php'));//提取部分文件 $zip->close(); echo 'ok'; } else { echo 'failed'; }
Recommended tutorial:PHP video tutorial
The above is the detailed content of How to decompress compressed package in php. For more information, please follow other related articles on the PHP Chinese website!