Posted By

Garciat on 10/20/09


Tagged


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

BrianCoyDesign


Unzip


 / Published in: PHP
 

  1. <?php
  2.  
  3. function unzip_to($file, $to)
  4. {
  5. $root = getcwd() . '/';
  6. $zip = zip_open($root . $file);
  7. while($zip_read = zip_read($zip))
  8. {
  9. $zip_file = $root . $to . zip_entry_name($zip_read);
  10. if(substr($zip_file, -1) == '/')
  11. mkdir($zip_file);
  12. else
  13. {
  14. touch($zip_file);
  15. $write = fopen($zip_file, 'w+');
  16. fwrite($write, zip_entry_read($zip_read));
  17. fclose($write);
  18. }
  19. }
  20. zip_close($zip);
  21. }
  22.  
  23. unzip_to('files/punbb-1.3.4.zip', './a/');

Report this snippet  

You need to login to post a comment.