createzipfromdir.php 675 B

12345678910111213141516171819202122
  1. <?php
  2. namespace zip\lib;
  3. class createDirZip extends createZip {
  4. function get_files_from_folder($directory, $put_into) {
  5. if ($handle = opendir($directory)) {
  6. while (false !== ($file = readdir($handle))) {
  7. if (is_file($directory.$file)) {
  8. $fileContents = file_get_contents($directory.$file);
  9. $this->addFile($fileContents, $put_into.$file);
  10. } elseif ($file != '.' and $file != '..' and is_dir($directory.$file)) {
  11. $this->addDirectory($put_into.$file.'/');
  12. $this->get_files_from_folder($directory.$file.'/', $put_into.$file.'/');
  13. }
  14. }
  15. }
  16. closedir($handle);
  17. }
  18. }
  19. ?>