没有 .
如果您知道,内容类型应该是已知的内容类型 . application/octet-stream 在RFC 2046中定义为"arbitrary binary data",其中's a definite overlap here of it being appropriate for entities whose sole intended purpose is to be saved to disk, and from that point on be outside of anything 291393 . Or to look at it from another direction; the only thing one can safely do with application/octet-stream is to save it to file and hope someone else knows what it'为 .
您可以将 Content-Disposition 与其他内容类型(例如 image/png 或甚至 text/html )结合使用,以表示您希望保存而不是显示 . 过去一些浏览器会在 text/html 的情况下忽略它,但我认为这是很久以前的事情(而且我现在不会开始测试一大堆浏览器;也许以后) .
RFC 2616还提到了扩展令牌的可能性,而且现在大多数浏览器都认为 inline 意味着你确实希望在可能的情况下显示实体(也就是说,如果它在这个问题上没有选择) . 这当然是默认行为,但这意味着您可以包含 Headers 的 filename 部分,浏览器将使用这些部分(可能需要进行一些调整,以便文件扩展名与所讨论的内容类型的本地系统规范相匹配,也许不是)作为用户试图保存的建议 .
因此:
Content-Type: application/octet-stream
Content-Disposition: attachment; filename="picture.png"
意思是“我不知道这到底是什么 . 请把它保存为文件,最好是名为picture.png” .
Content-Type: image/png
Content-Disposition: attachment; filename="picture.png"
表示“这是PNG图像 . 请将其保存为文件,最好命名为picture.png” .
Content-Type: image/png
Content-Disposition: inline; filename="picture.png"
表示“这是PNG图像 . 除非您不知道如何显示PNG图像,否则请显示 . 否则,或者如果用户选择保存它,我们建议您将文件名为picture.png保存为” .
在识别 inline 的那些浏览器中,有些人总是会使用它,而有些人会在用户选择"save link as"时使用它,但如果他们在查看时选择了"save"则不会使用它(或者至少IE曾经是这样的,它可能已经改变了几年前) .