duandu2159 2015-05-20 13:43
浏览 1852

资源解释为Document但使用MIME类型application / octet-stream控制台传输

I have a file management system I'm building where only zip files are allowed. I dont want anyone to see where the file is stored on the server so I'm using an ajax call to a php file that executes the following:

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);

    }
}

The file downloads fine but it pumps out a console message pointing out the file location:

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

1条回答 默认 最新

  • drxpt06820 2015-05-28 17:55
    关注

    Seems to be normal on chrome when we try to download any file directly by entering its url in the browser. Tried downloading Chrome, Firefox & GitHub for windows and they all behaved the same way on chrome.

    While giving a download link you can fix the same by adding download attribute inside tag.

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

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题