Код: Выделить всё
// start downloading
require_once 'classes/class-FlxZipArchive.php';
$filename = 'update_'.time();
$path = 'updates'.DIRECTORY_SEPARATOR.$update;
$zip = new FlxZipArchive;
$zip->open($filename.'.zip',ZipArchive::CREATE);
$zip->addDir($path,basename($path));
$zip->close();
if(file_exists($filename.'.zip')){
header("Content-type: application/zip");
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Disposition: attachment; filename=".$filename.".zip");
header("Content-length: ".filesize($filename.'.zip'));
header("Pragma: no-cache");
header("Expires: 0");
readfile($filename.'.zip');
unlink($filename.'.zip');
};
exit;
Предположим, у меня есть файл files.zip со следующим содержимым:
Код: Выделить всё
- folder
- images
- image1.png
- image2.png
- docs
- doc1.docx
- doc2.docx
Где моя ошибка?
Я использую следующий класс: https://gist.github.com/panslaw/4327882
Изменить:
код работает как ожидалось, но я использовал Mac с настройками для автоматической загрузки и извлечения файлов «сохранения». Дополнительная информация здесь: https://wiki.umbc.edu/pages/viewpage.ac ... d=31919091