My code creates a ZIP file and downloads it in this ZIP folder some images exist.
It’s done well but problem is that after I download and extract this folder then all path folder also become my code is:
$id = $row['id'];
$doc_name = $row['doc_name'];
$file_names = explode(',',$doc_name);
$file_path = $_ROOT_REQUIRE."uploads/document/";
$archive_file_name = "demo.zip";
$zip = new ZipArchive($archive_file_name);
if ($zip->open($archive_file_name, ZIPARCHIVE::CREATE ) !== TRUE) {
echo "cannot open <$archive_file_name>\n";
exit("cannot open <$archive_file_name>\n");
}
foreach ($file_names as $files) {
if ($files !== '') {
$zip->addFile("$files", basename($files));
}
}
$zip->close();
header('Content-type: application/zip');
header('Content-Disposition: attachment; filename="'.basename($archive_file_name).'"');
header('Content-Transfer-Encoding: binary');
header('Content-Length: '.filesize($archive_file_name));
header('Cache-Control: private');
ob_clean();
flush();
readfile(basename($archive_file_name));
exit;