The example in this article describes how PHP extracts zip files online. Share to everyone for your reference. The specific analysis is as follows:
In the PHP function library only found a zlib function also with compression somewhat, but I was disappointed that he did not solve the zip file, but finally let me find the solution, is through the PHP program execution function to achieve this function, because now can solve the zip file is too much, If you do not believe, you can go to the download software where to look for, categorization malleability you will not be disappointed, my words will not be wrong.
Here is the original file of the program, the upload.php code is as follows:
<table border= "0" > <form enctype= "Multipart/form-data" action= "upsave.php" method= "POST" > <tr > <td> if it is *. The zip file will be automatically decompressed <input name= "MyFile" type= "file" size= "> </td> </tr> <tr> <td colspan= "2" align= "center" > <input type= "Submit" value= "upload" class=iwhite> <input Type= "Reset" value= "refill" class=iwhite> </td> </tr> </table> </body>
The upsave.php code is as follows:
<?php//Save uploaded file $filename = "$MyFile _name"; Copy ($MyFile, "$filename"); Unlink ($MyFile); Determine if the 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 above procedures I have tested, as long as the server can be put on, but the directory to have write permissions, there is a Pkunzip.exe file to be placed in the directory.
I hope this article is helpful to everyone's PHP programming.
Related articles:
Generate Zip Compressed files from PHP, support file and archive path lookup
How to use PHP to generate zip compressed files with detailed code
Simple PHP method for creating Zip compressed files