Solve the file name decompression after the problem of garbled code will file name transcoding code

  • 2020-05-12 02:19:45
  • OfStack

 
<?php 
$a=zip_open('other.zip'); 
while ($e=zip_read($a)){ 
$fz = zip_entry_filesize($e); 
$fn = iconv('GBK','UTF-8',zip_entry_name($e)); 
if (!$fz){//dir 
mkdir($fn); 
continue; 
} 
if (!zip_entry_open($a, $e)) 
continue; 
file_put_contents($fn, zip_entry_read($e, $fz)); 
echo "$fz\t$fn\n"; 
zip_entry_close($e); 
} 
zip_close($a); 
?> 

Related articles: