内容处置:附件不会强制下载为附件

时间:2017-01-24 18:40:15

标签: php mysql http-headers

正如标题所示,尽管将内容处置标头设置为附件,并且看到从服务器成功返回的二进制数据,但它根本不会触发下载。

文件作为BLOB存储在mysql数据库中,我的浏览器是Chrome 55。

我的代码:

$doc = $database->getDocument($docId);

$filename = $doc['name'];
$filetype = $doc['type'];
$filecontent = $doc['content'];

header('Content-Type: ' . $filetype);
header('Content-length: ' . strlen($filecontent));
header('Content-disposition: attachment; filename=' . '"' . $filename . '"');
echo $filecontent;

response headers

preview

我尝试将内容类型更改为' application / octet-stream'以及更改“附件”中的“内容 - 处置”。下载'没有运气。

我不知道问题是什么,如果有人能够解释这个问题,我将不胜感激。

0 个答案:

没有答案