Php 解释为文档但使用MIME类型应用程序/八位字节流控制台传输的资源

Php 解释为文档但使用MIME类型应用程序/八位字节流控制台传输的资源,php,ajax,download,zip,console.log,Php,Ajax,Download,Zip,Console.log,我正在构建一个文件管理系统,其中只允许使用zip文件。我不想让任何人看到文件在服务器上的存储位置,因此我使用ajax调用php文件,执行以下操作: if (!empty($find_url)) { foreach ($find_url as $file) { $dl = urldecode($file->file_url); } $file_headers = @get_headers($dl); if($file_headers[0] =

我正在构建一个文件管理系统,其中只允许使用zip文件。我不想让任何人看到文件在服务器上的存储位置,因此我使用ajax调用php文件,执行以下操作:

if (!empty($find_url)) {
    foreach ($find_url as $file) {
        $dl =  urldecode($file->file_url);
    }
    $file_headers = @get_headers($dl);
    if($file_headers[0] == 'HTTP/1.1 404 Not Found') {
        $exists = false;
    } else {

        $exists = true;
        header('Content-Type: application/zip');
        header("Content-Transfer-Encoding: Binary"); 
        header('Location: '.$dl);

    }
}
该文件下载正常,但会输出一条控制台消息,指出文件位置:

Resource interpreted as Document but transferred with MIME type application/octet-stream: 
"http://www.exmple.co.uk/someplace/filename.zip".

当我们试图通过在浏览器中输入文件的url直接下载任何文件时,在chrome上似乎是正常的。尝试下载Chrome、Firefox和GitHub for windows,它们在Chrome上的表现都是一样的

在提供下载链接时,您可以通过在标记中添加下载属性来修复相同的问题

<a href="http://www.exmple.co.uk/someplace/filename.zip" download>Download File</a>

是的,我已经研究了HTML5下载属性。但我真的在寻找一个更好的浏览器兼容选项。我想我还应该提到,它获取zip文件位置的方式是通过一个通过AJAX/PHP加密的URL完成的。可能不是对这个过程的最好描述。很抱歉