Unzip zip files


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  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. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.