This article describes how to decompress the ZIP file online by using php, including the complete upload and zip decompression functions, which are of great practical value, for more information about how to decompress the ZIP file online, see the example in this article. Share it with you for your reference. The specific analysis is as follows:
In the PHP function library, only ZLIB functions are found to be related to compression, but I was disappointed that he could not solve the ZIP file, but in the end, I still found a solution, that is, to implement this function through the PHP program execution function, because there are too many things that can solve ZIP files now. if you don't believe it, you can go to the place where you have downloaded the software to find it. make sure that you will not be disappointed. I will not be wrong.
The following is the original file of the program. The upload. php code is as follows:
The code is as follows:
If the file is *. ZIP, it will be automatically decompressed.
|
|
The upsave. php code is as follows:
The code is as follows:
<? Php
// Save the uploaded file
$ Filename = "$ MyFile_name ";
Copy ($ MyFile, "$ filename ");
Unlink ($ MyFile );
// Determine whether the file 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 );
}
?>
The secret file should also be placed in this directory.
I hope this article will help you with php programming.