rakeshr

photo-gallery-download-all-images

Jun 1st, 2015
333
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.60 KB | None | 0 0
  1. <?php
  2.  
  3.     $zipname = 'yec-photos.zip';
  4.     $zip = new ZipArchive;
  5.     $zip->open($zipname, ZipArchive::CREATE);
  6.     if ($handle = opendir('.')) {
  7.       while (false !== ($entry = readdir($handle))) {
  8.         if ($entry != "." && $entry != ".." && !strstr($entry,'.php')) {
  9.             $zip->addFile($entry);
  10.         }
  11.       }
  12.       closedir($handle);
  13.     }
  14.  
  15.     $zip->close();
  16.  
  17.     header('Content-Type: application/zip');
  18.     header("Content-Disposition: attachment; filename='yec-photos.zip'");
  19.     header('Content-Length: ' . filesize($zipname));
  20.     header("Location: yec-photos.zip");
  21.  
  22.     ?>
Add Comment
Please, Sign In to add comment