使zip文件无法创建和下载时显示仅zip名称的问题
if (file_exists($filename)) {
header("HTTP/1.1 200 OK");
header("Pragma: public");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private", false);
$mimeType = 'application/json';
header("Content-type: " . $mimeType);
header("Content-Disposition: attachment; filename=\"{$filename}\"");
header("Content-Transfer-Encoding: binary");
header("Content-Length: " . mb_strlen($filename));
echo $filename;
flush();
readfile($filename);
// delete file
unlink($filename);
}
答案 0 :(得分:0)
尝试这样设置Content-type:header("Content-type: application/zip");