首页 > 解决方案 > Chrome 和 Firefox 阻止下载动态创建的 zip 文件,称这是不寻常的下载并且可能有害

问题描述

Google Chrome 和 Mozilla Firefox 将我的 zip 文件归类为可能有害。

这是用户在下载 zip 文件时看到的内容

我写了一些代码(PHP,Codeigniter),它动态地创建了一个 zip 文件,让用户立即下载它。这种代码和平只有在用户登录后才能访问。在 localhost 上一切正常,但在生产环境中,Google Chrome 和 Mozilla firefox 将 zip 文件归类为可能有害。

产品使用 RapidSSL 的域验证证书进行 HTTPS 加密。

我做了一些研究,发现:

我尝试了 codeigniter zip 库和 PHP 的 ZipArchive。两种解决方案都有同样的问题。在使用 PHP 的 ZipArchive 创建 zip 文件后,我为下载设置的标题如下:

//Set the Content-Type, Content-Disposition and Content-Length headers.
header("Content-Type: application/zip");
header("Content-Disposition: attachment; filename=$zip_name");
header("Content-Length: " . filesize($zip_path_and_filename));

//Read the file data and exit the script.
readfile($zip_path_and_filename);
exit;

我希望下载 zip 文件时不会将其归类为潜在有害文件。事实上,Microsoft Edge 并没有抱怨什么。

标签: phpgoogle-chromesecurityfirefoxzip

解决方案


推荐阅读