Posted By

fackz on 07/21/09


Tagged

php file unzip unizp


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

fackz
irishsk
tux-world


Unzip file using PHP


 / Published in: PHP
 

URL: http://ranacse05.wordpress.com/2008/03/20/unzip-file-using-php/

A few days ago i was looking for a script witch one will help me to unzip a file using PHP . There is 2 different ways to do it.One just execute a commend to unzip the file in the shell using PHP and another one is using library functions

  1. <?php
  2.  
  3. // create object
  4. $zip = new ZipArchive() ;
  5.  
  6. // open archive
  7. if ($zip->open(’archive. zip’) !== TRUE) {
  8. die (’Could not open archive’);
  9. }
  10.  
  11. // extract contents to destination directory
  12. $zip->extractTo(/ tmp/extracted/);
  13.  
  14. // close archive
  15. // print success message
  16. $zip->close();
  17. echo ‘Archive extracted to directory’;
  18.  
  19. ?>

Report this snippet  

You need to login to post a comment.