出现“已发送标头”警告。我关闭$zip->close();
但仍显示警告
$zip = new ZipArchive;
$download = 'new_zip.zip';
$zip->open($download, ZipArchive::CREATE);
foreach (glob("zipfile/*") as $file) {
$zip->addFile($file);
}
$zip->close();
header('Content-Type: application/zip');
header("Content-Disposition: attachment; filename = $download");
header('Content-Length: ' . filesize($download));
header("Location: $download");
答案 0 :(得分:1)
在脚本开头,使用:
<?php ob_start(); ?>
然后在脚本的末尾添加:
<?php ob_flush(); ?>