在zend中使用Tcpdf并且无法将文件添加到zip 这就是我试过的
require_once('eng.php');
require_once('tcpdf.php');
$pageLayout = array(750, 800);
$content=Array(
'<html><body>Document A</body></html>',
'<html><body>Document B</body></html>',
'<html><body>Document C</body></html>'
);
$zip = new ZipArchive();
$filename = "/tmp/final.zip";
$zip->open($filename, ZipArchive::CREATE);
foreach($content as $i=>$html){
$pdf =new TCPDF('P', 'pt', $pageLayout, true, 'UTF-8', false);
$pdf->SetCreator(PDF_CREATOR);
$pdf->AddPage();
$pdf->writeHTML($html, true, false, true, false, '');
$pdf->lastPage();
$pdf->Output('/tmp/filename_' . $i . '.pdf', 'F');
if(!file_exists('/tmp/filename_' . $i . '.pdf')){
echo "File Doesn't Exist...";exit;
}
$zip->addFile('/tmp/filename_' . $i . '.pdf','filename_' . $i . '.pdf');
}
$zip->close();
header('Content-type: application/zip');
header('Content-Disposition: attachment; filename="final.zip"');
readfile($filename);
给出错误
警告:fopen(file:///tmp/filename_179367.pdf):无法打开 stream:没有这样的文件或目录....