Home  >  Article  >  Backend Development  >  PHP decompress zip file

PHP decompress zip file

WBOY
WBOYOriginal
2016-07-25 08:45:21929browse
Can decompress zip files. It has two parameters: the path of the compressed file and the path of the target file.
  1. function unzip_file($file, $destination) {
  2. // create object
  3. $zip = new ZipArchive() ;
  4. // open archive
  5. if ($zip->open($file) !== TRUE ) {
  6. die ('Could not open archive');
  7. }
  8. // extract contents to destination directory
  9. $zip->extractTo($destination);
  10. // close archive
  11. $zip->close();
  12. echo 'Archive extracted to directory';
  13. }
Copy code

Unzip, PHP, zip


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn