我尝试使用以下代码从服务器下载文件,但未下载。它仅显示浏览器中的内容
<?php
if(file_exists($zipName))
{
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename=\'Uttam_Solanki.zip\'');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($zipName));
readfile($zipName);
exit;
}
?>
最佳答案
您需要更改 .htaccess 中的角色
添加应用程序/八位字节流 zip
关于php - 强制从服务器下载 zip 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38597773/