Advertisement
Guest User

ziping

a guest
May 30th, 2015
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.67 KB | None | 0 0
  1. <?
  2. // increase script timeout value
  3. ini_set("max_execution_time",
  4. 300);
  5. // create object
  6. $zip = new ZipArchive();
  7. // open archive
  8. if ($zip->open("my-archive.zip",
  9. ZIPARCHIVE::CREATE) !== TRUE) {
  10. die ("Could not open archive");
  11. }
  12. // initialize an iterator
  13. // pass it the directory to be
  14. processed
  15. $iterator = new
  16. RecursiveIteratorIterator(new
  17. RecursiveDirectoryIterator
  18. ("app/"));
  19. // iterate over the directory
  20. // add each file found to the
  21. archive
  22. foreach ($iterator as $key=>$
  23. value) {
  24. $zip->addFile(realpath($key), $
  25. key) or die ("ERROR: Could not
  26. add file: $key");
  27. }
  28. // close and save archive
  29. $zip->close();
  30. echo "Archive created
  31. successfully.";
  32. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement