我有这个代码
<?php
$files = array('includes/s.xlsx', 'includes/test.html');
$zipname = 'file.zip';
$zip = new ZipArchive;
$zip->open($zipname, ZipArchive::CREATE);
foreach ($files as $file) {
$zip->addFile($file);
}
$zip->close();
header('Content-Type: application/zip');
header('Content-disposition: attachment; filename=filename.zip');
header('Content-Length: ' . filesize($zipname));
readfile($zipname);
但我不想将 zip 文件保存到服务器,我只想将它提供给用户。