Я храню блоб в базе данных и успешно преобразовал его в PDF. Я использую этот код.
header('Content-type: application/pdf');
header("Cache-Control: no-cache");
header("Pragma: no-cache");
header("Content-Disposition: attachment;filename=".$this->pdfName);
header("Content-length: ".strlen($res[0]['comp_statement']));
$this->pdf = $res[0]['comp_statement']
echo $res[0]['comp_statement'];
Существует два варианта в Content-Disposition ethier, которые вы можете скачать или показать на веб-странице. Я не хочу, чтобы показать или скачать. Я хочу поместить его в zip-каталог, который я создаю динамически.
Здесь код для zip-архива
$zip = new ZipArchive;
$zipName = $this->currentCompYear.'.zip';
if ($zip->open($zipName, ZipArchive::CREATE | ZipArchive::OVERWRITE) === TRUE) {
if(!$zip->locateName($this->currentCompYear)) {
$zip->addEmptyDir($this->currentCompYear);
}
if(!$zip->locateName($regionDir)) {
$zip->addEmptyDir($regionDir1);
}
if(!$zip->locateName($managerDir)) {
$zip->addEmptyDir($managerDir1);
}
$zip -> addFile($this->pdf));// I want to add my pdf file here
$zip->close();
ob_clean();
header("Content-type: application/zip");
header("Content-Disposition: attachment; filename=".$zipName);
header("Content-length: " . filesize($zipName));
header("Pragma: no-cache");
header("Expires: 0");
readfile($zipName);
Any Clue.