PHP decompress ZipArchive's extracloud () method. The File loss problem occurs when zip is decompressed in LINUX and nginx environments.

Source: Internet
Author: User
Tags ziparchive
Use ZipArchive to decompress the ZIP file in the project. the Test environment is in the WINDOWS platform and passes the test, changing to a LINUX + nginx environment causes a problem (the ZIP package contains more than 3 hundred files and folders, most of which are file names with Chinese characters ), the problem is that ZipArchive is used to decompress the ZIP file in the project. at first, the test environment is in WINDOWS, and the test passes, changing to a LINUX + nginx environment causes a problem (the ZIP package contains more than 3 hundred files and folders, most of which are file names with Chinese characters). The problem is: there is no problem in extracting files without Chinese characters. In addition, there are no problems in extracting some files with Chinese characters and numbers, and the names of other files with pure words are lost and no error is reported, finally, the problem is located in the extracloud () method. Nima is an encapsulated method and the actual source code is invisible. However, we can find all the files for ($ I = 0; $ I <$ zip-> numFiles; $ I ++). The number of files is normal, the copy link after decompression occurs. Can I use this loop to decompress the package and copy the file by myself ?? For ($ I = 0; $ I <$ zip-> numFiles; $ I ++) {$ filename = $ zip-> getNameIndex ($ I); if (! Is_dir ($ filename) {copy ("zip ://". $ path. "#". $ filename, $ topath. $ filename);} else {@ mkdir ($ topath. '/'. $ filename, 0777) ;}} solved the problem. It took me a day to find this problem !! I hope to help those who lost the same file during decompression.

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.