Home  >  Article  >  Backend Development  >  PHP online decompression ZIP file example code_PHP tutorial

PHP online decompression ZIP file example code_PHP tutorial

WBOY
WBOYOriginal
2016-07-20 11:07:351027browse

In the PHP function library, I only found a ZLIB function that has something to do with compression, but what disappointed me was that it could not decode ZIP files (hey... I had to give up. Please don't say that I have no perseverance!! ! ). But as the saying goes: Hard work pays off!

In the PHP function library, I only found a ZLIB function that has something to do with compression, but what disappointed me was that it failed to decode the ZIP file (Hey... I had to give up, everyone. Don’t say I don’t have perseverance!). But as the saying goes: Hard work pays off! In the end, I found a solution, which is to implement this function through PHP's program execution function, because there are so many things that can decode ZIP files (if you don't believe it, you can look for it where you can download the software) , I guarantee you will not be disappointed, my words are not wrong).

The following is the original file of the program:

#upload.php tutorial










If it is a *.ZIP file, it will be automatically decoded Compression










//upsave.php
//Save the uploaded file
$filename="$MyFile_name" ;
copy($MyFile,"$filename");
unlink($MyFile);

//Determine whether it is a ZIP file
$expand_name=explode(".",$ filename);
if($expand_name[1] == "zip" or $expand_name[1] == "ZIP")
{
$str="pkunzip.exe -e $filename ";
exec($str);
unlink($filename);
}

?>



I have tested the above program , just put it on the server, but the directory must have write permissions. There is also a pkunzip.exe file that should also be placed in this directory. This file has been placed in the compressed package.


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/444932.htmlTechArticleIn the PHP function library, I only found a ZLIB function that has something to do with compression, but it disappointed me It was because he couldn't decode the ZIP file (Hey... I had to give up. Don't say I don't have perseverance...
Statement:
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