我想强制下载..在IE中我得到一个错误,但在FF中没有问题
header("Content-Type: application/force-download\n");
header("Content-Disposition: attachment; filename=test.txt");
echo 'test file';发布于 2011-04-08 19:50:14
我刚刚在谷歌上搜索了你好奇的application/force-download mime类型。我不知道是谁“发明”了这个,但看起来,它根本就不存在。请参阅http://mimeapplication.org/force-download.html
这意味着IE可能不喜欢它。请改用application/octet-stream。据我所知,firefox会为每种mime类型打开一个下载对话框,要么注册了"show download dialog",要么根本不知道。在这种情况下,FF可能不知道类型。
发布于 2011-06-01 15:28:04
这可能对你有帮助,对我很管用
header('Content-Type: application/force-download');
header("Content-disposition: attachment; filename=$filename");
flush();
readfile($filename);
exit;如果需要,您可以添加其他标头:)
https://stackoverflow.com/questions/5594526
复制相似问题