Za to ces morati da koristis php.
Kreiraj stranicu download.php (ili neko drugo ime) i dodaj kod:
Code:
<?php
$rootPath = realpath('../public'); // path do root foldera za skidanje
$zip = new ZipArchive(); // kreiranje zip-a
$zip_file = 'file.zip';
$zip->open($zip_file, ZipArchive::CREATE | ZipArchive::OVERWRITE);
$files = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($rootPath),
RecursiveIteratorIterator::LEAVES_ONLY
);
foreach ($files as $name => $file) {
if (!$file->isDir()) {
$filePath = $file->getRealPath();
$relativePath = substr($filePath, strlen($rootPath) + 1);
$zip->addFile($filePath, $relativePath);
}
}
$zip->close();
// DOWNLOAD kreiranog zipa
header('Content-type: application/zip');
header('Content-Disposition: attachment; filename="'.basename($zip_file).'"');
header("Content-length: " . filesize($zip_file));
header("Pragma: no-cache");
header("Expires: 0");
ob_clean();
flush();
readfile($zip_file);
unlink($zip_file); // Obrisi zip da ne zauzima prostor
exit;
Posle samo otvori tu stranicu 'download.php'
Postavi i neku zastitu da ne moze bas svako da pristupi stranici.
Obavezno testiraj pre nego postavis na server (sigurno radi, koristio sam davno, al' ipak proveri)