【发布时间】:2011-05-14 04:10:27
【问题描述】:
现在我用 php(后来用 nodejs 代替)发送文件下载的标题,如下所示:
<?php
// example array for .exe (for IE, doesnt work)
// i also tried x-msdownload
$file = array( 'octet-stream', 'download.exe' );
header( 'HTTP/1.0 200 OK' );
header( 'Content-Type: application/'.$file[0] );
// thats the part that doesnt work - i tried inline; attachment; with quotes, without quotes, single quotes, ending ; no ending ;...
header( 'Content-Disposition: filename="'.$file[1].'";' );
header( 'Content-Length: '.filesize( $file[1] ) );
readfile( $file[1] );
exit;
?>
结果总是一样的 - 我将下载内容重写到这样的文件夹中: /download/123/ - content-disposition 标头应该回复正确的文件名,但 IE 显示为文件名“123”和“未知文件类型”......现在即使我将 ID 之后的所有内容都重写到文件夹 index.php 并请求例如:/download/123/something.exe 它仍将显示为下载“某物”和“未知文件类型”。无论我设置什么内容类型或我如何排序内容处置的值。
据我所知,这是一个常见的 IE 问题,但从未得到解决 - 有人知道解决此问题的方法吗?
谢谢!
编辑:只是为了确保每个人都知道我想要什么作为正确的结果:IE 应该得到它的 .EXE 文件并提供“运行 - 保存 - 取消”对话框而不是“未知文件类型”标准“查找 -保存 - 取消”对话框。顺便提一句。如果我点击 find ,它会将我重定向到 microsoft 页面,该页面解释了 x-msdownload 是什么(现在设置为 content-type)...
【问题讨论】:
-
fyi - 我在 OSX 上,目前 IE7 以交叉方式运行,但我与我的同事 windows 框确认,他也运行 IE7 和另一个运行 IE8 的人都运行相同的结果。
标签: php internet-explorer http-headers