The test code is as follows:
The code is as follows: |
Copy code |
// PHP decompress the file (zip) Function unzip_file ($ file, $ destination ){ $ Zip = new ZipArchive (); // Open the compressed file If ($ zip-> open ($ file )! = TRUE ){ Die ('could not open Archive '); } // Create a file $ Zip-> extrac.pdf ($ destination ); $ Zip-> close (); Echo 'successfully '; } Unzip_file ("htdocs.zip", "wenjianming "); |
Detected during execution
Fatal error: Class 'ziparchive 'not found in E: wwwqqdown. php on line 63
I think this is not undefined, so I search Baidu for it as follows:
In Windows, the solution is:
1. In the php. Ini file, remove the semicolon ";" Before extension = php_zip.dll;
Restart the Apache server. We can try again.
For a linux system, refer to the following method.
There is no php_zip.dll file in Linux.
You need to recompile the php zip module. The installation method is as follows:
The code is as follows: |
Copy code |
Cd/usr/src Wget http://pecl.php.net/get/zip Tar-zxvf zip Cd zip-1.x.x Phpize ./Configure Make Sudo make instal |
The root permission may be required when you use the make install command. Therefore, we recommend that you use sudo to run the command. After installation, the location of zip. so is displayed. Record it, for example,/usr/local/lib/php/extensions/zip. so.
2. Use root permission to modify php. ini (usually in the/usr/local/lib/folder, but depending on the initial installation of php, you can view it through phpinfo ):
Add extension =/usr/local/lib/php/extensions/zip. so, and change zlib. output_compression = Off to zlib. output_compression = On in the php. Ini file;
3. Do not forget to restart Apache: apachectl restart;
Note: some friends on the website say zlib. change output_compression = Off to zlib. output_compression = On; I have not operated On php in windows. the INI file is not seen yet, but the file can be generated or decompressed.