Answer the question
In order to leave comments, you need to log in
How to get a link to download the archive?
There is a PHP code that creates a ZIP archive from files, and when the page is loaded (with this code), a window appears for downloading this archive.
# create new zip opbject
$zip = new ZipArchive();
# create a temp file & open it
$tmp_file = tempnam('.', '');
$zip->open($tmp_file, ZipArchive::CREATE);
# loop through each file
foreach($newArray as $file) {
# download file
$download_file = file_get_contents($file);
# add it to the zip
$zip->addFromString(basename($file), $download_file);
}
# close zip
$zip->close();
# send the file to the browser as a download
header('Content-disposition: attachment; filename=download.zip');
header('Content-type: application/zip');
readfile($tmp_file);
Answer the question
In order to leave comments, you need to log in
Write on the page
<a href="путь до вашего php" download="имя которое получит ваш архив при скачивании.zip">Скачать архив</a>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question