Decompress the uploaded ZIP file using PHP

Source: Internet
Author: User

Decompress the uploaded ZIP file using PHP (for conversion)
Caoli was published on 10:48:20 PHP programming Forum return page

Not long ago, when I browsed the webpage, I accidentally found that the home page bus www.chinaren.com was able to automatically decompress the uploaded ZIP file, more interesting to me is that its function is to use PHP. Considering that I will also use some PHP, I decided to try it.

After some searching, I found only a ZLIB function in the PHP function library, which has a relationship with compression, but I was disappointed that he could not solve the ZIP file (ah .... I had to give up. Don't say I have no perseverance !!!). But as the saying goes: Do it mean you have to pay for it! Finally, let me find the 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 do not believe it, you can go to the place where you have downloaded the software to find it, so you will not be disappointed, and I will not be wrong ).

The following is the original file of the program:

# Upload. php




If the file is *. ZIP, it will be automatically decompressed.


















// Upsave. 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 );
}

?>

I have tested the above programs. You only need to put them on the server, but the directory must have the write permission. A pkunzip.exe file must also be stored in this directory, which is already in the compressed package.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.