Skip to content

Commit

Permalink
download zip of site fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
btopro committed Feb 19, 2019
1 parent 9f8baea commit be78960
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions system/downloadSite.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,19 @@
$zip = new ZipArchive();
$zip->open($zip_file, ZipArchive::CREATE | ZipArchive::OVERWRITE);
// Create recursive directory iterator
$files = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($rootPath),
RecursiveIteratorIterator::LEAVES_ONLY
);
$directory = new RecursiveDirectoryIterator($rootPath);
$filtered = new DirFilter($directory, array('.git', 'node_modules'));
$files = new RecursiveIteratorIterator($filtered);
foreach ($files as $name => $file) {
// Skip directories (they would be added automatically)
if (!$file->isDir()) {
// Get real and relative path for current file
$filePath = $file->getRealPath();
$relativePath = substr($filePath, strlen($rootPath) + 1);
// Add current file to archive
$zip->addFile($filePath, $relativePath);
if ($filePath != '' && $relativePath != '') {
$zip->addFile($filePath, $relativePath);
}
}
}
// Zip archive will be created only after closing object
Expand Down

0 comments on commit be78960

Please sign in to comment.