使用content-disposition提供的文件:内联有时会提示下载 [英] files served with content-disposition: inline still sometimes prompt for download

查看:118
本文介绍了使用content-disposition提供的文件:内联有时会提示下载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的主题说明了我要问的大部分内容。我有一个网站,可以输出各种格式的报告(HTML,CSV,TSV,Excel等)。只要有可能,我希望这些文件能够在浏览器中显示。为此,我设置了标题,以便Content-Disposition为inline。这与不同的文件类型非常不一致。似乎在FF3和IE7中,HTML将始终自动打开内联。这就说得通了。如果我使用TSV,两个浏览器都会提示下载,因为它是我系统上的未知文件类型。这也很有意义,正是我想要的。但是,Excel和CSV提供不同的行为。在FF中,两者始终提示下载或打开。如果我选择打开,它将在新窗口中打开。在IE中,提示下载或打开 - 我无法想出这个。我认为使用Content-Disposition自动内联Excel文件:inline。如果我在IE中选择打开,它会在浏览器中内联打开。

My subject line says most of what I'm asking. I've got a web site that outputs reports in various formats (HTML, CSV, TSV, Excel, etc). Whenever possible, I'd like these files to be shown in the browser. To that end, I've set up my headers so that "Content-Disposition" is "inline". This works very inconsistently with different file types. It seems that in both FF3 and IE7, HTML will always open inline automatically. That makes sense. If I use TSV, both browsers will prompt for download, since it's an unknown file type on my system. That also makes sense and is exactly what I want. Excel and CSV, however, offer different behaviors. In FF, both always prompt for download or opening. If I choose "open", it opens in a new window. In IE, both also prompt for download or opening -- I can't figure this one out. I thought Excel files opened inline automatically with Content-Disposition: inline. If I choose "open" in IE, it opens inline in the browser.

有人可以解释意外行为吗?对我来说这不是一个真正的问题,但我的用户认为这是一个错误,所以我可以引用他们的权威来源将是非常好的。到目前为止我唯一发现的关于这个问题的事情就是在mozilla论坛上发布一篇关于自动开放式内容是IE的安全漏洞的帖子,这是一个很老的帖子,所以也许吧在IE7中被修复了吗?谢谢。

Can someone explain the unexpected behavior? This isn't really a problem for me, but my users think it's a bug, so an authoritative source I can cite to them would be excellent. The only thing I've found so far about this "issue" is a 1 line post on a mozilla forum about how the auto-open-inline thing is one of IE's security flaws... that was an old post, so maybe it was "fixed" in IE7? Thanks.

推荐答案

您可能已经解决了这个问题,但如果没有,我可能会有一个答案(对于同样问题的未来人士) ,这也让我疯了!)

You may have resolved this already, but if not I may have an answer (for future people with the same issue, this also drove me nuts!)

可以使用以下方法在客户端上覆盖此行为:

This behavior can be overwritten on the client, using the following:


  1. 转到Windows资源管理器

  2. 选择工具 - >文件夹选项

  3. 选择文件类型选项卡

  4. 查找扩展名DOC(或PDF等)

  5. 选择高级

  6. 勾选/取消下载后根据需要确认打开。

  1. Go to windows explorer
  2. Select Tools -> Folder Options
  3. Select "File Types" Tab
  4. Find extension "DOC" (or "PDF", etc)
  5. Select "Advanced"
  6. Tick / Untick "Confirm open after download" as desired.

用于实现预览/下载功能的机制是通过使用内容 - 处理标题,通常使用MimeType应用程序/。这基本上告诉本地客户端使用指定的应用程序打开应用程序,但是应用程序的上述设置可以覆盖请求的交付格式。

The mechanism used to implement the preview / download functionality is via the use of the "content-disposition" header, usually using MimeType "application/". This basically tells the local client to open the application using the specified application, however the above settings for the application can overwrite the requested delivery format.

这篇关于使用content-disposition提供的文件:内联有时会提示下载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆