Home > Backend Development > PHP Tutorial > Server-side decompression zip script_PHP tutorial

Server-side decompression zip script_PHP tutorial

WBOY
Release: 2016-07-21 15:58:33
Original
707 people have browsed it

Copy code The code is as follows:
  
  
  
  
文件解压缩管理  
  
  
// In PHP versions earlier than 4.1.0, $HTTP_POST_FILES should be used instead  
// of $_FILES.  
if (isset($_POST["Submit"])) {  
   echo "FileName:     " . $_POST['unpackfile'] . "n";  
   echo "UnpackPath:   " . $_POST['unpackpath'] . "n";  
   $zip = zip_open($_POST['unpackfile']);  
   if ($zip) {  
      while ($zip_entry = zip_read($zip)) {  
         echo "Name:               " . zip_entry_name($zip_entry) . "n";  
         echo "Actual Filesize:    " . zip_entry_filesize($zip_entry) . "n";  
         echo "Compressed Size:    " . zip_entry_compressedsize($zip_entry) . "n";  
         echo "Compression Method: " . zip_entry_compressionmethod($zip_entry) . "n";  

         if (zip_entry_open($zip, $zip_entry, "r")) {  
            $buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));   // File content  
            echo "step 1 successful!n";  
            if(zip_entry_filesize($zip_entry)!=0) {  
               $fp = fopen($_POST['unpackpath']."/".zip_entry_name($zip_entry), 'wb');  
               fwrite($fp, $buf);  
               fclose($fp);  
               zip_entry_close($zip_entry);  
               echo "unpack successful!n";  
            } else {  
               mkdir($_POST['unpackpath']."/".zip_entry_name($zip_entry), 0777);  
               echo "mkdir successful!n";  
            }  
         }  
         echo "

nn";  
      }  
      zip_close($zip);  
   }  
?>  
  
  
exit();  
}
?>

File to be decompressed
Decompression path



www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/317559.htmlTechArticleCopy the code as follows: !DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http: //www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" htmlxmlns="http://www.w3.org/1999/xhtml"...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template