开发者

How Can I stop Internet Explorer from automatically displaying XML?

开发者 https://www.devze.com 2022-12-09 21:46 出处:网络
Is there anyway to force Internet Explorer to prompt for download of XML files instead of automatically displaying them? A code solution or just a set of IE configuration steps would be fine.

Is there anyway to force Internet Explorer to prompt for download of XML files instead of automatically displaying them? A code solution or just a set of IE configuration steps would be fine.

Even 开发者_运维问答if I use the wrong extension, IE uses "content sniffing" to determine that is XML and opens it automatically anyway.

I'd rather have the Open/Save/Cancel dialog instead.

Thanks in advance


You need to set the Content-Disposition HTTP header to "attachment". Doing this will be different depending on which framework or web-server you're using. For instance, in PHP you can use the following code:

header('Content-Disposition: attachment; filename="myfile.xml"');
header('Content-Type: application/xml');
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号