如何使用内容类型:多部分/相关

发布于 2024-09-14 13:18:03 字数 675 浏览 7 评论 0原文

我想向用户发送一个二进制文件,并在浏览器上显示一些 HTML。我正在使用 apache2 的 CGI-BIN 脚本。我在第 4 页找到了此示例。该链接还显示有关多部分/相关内容类型的详细信息。这是我到目前为止所尝试的:

Content-Type: Multipart/Related; boundary="boundary-content"; start=""; type=\"text/plain\""

--boundary-content
Content-Disposition: inline
Content Type:text/plain
Content-ID: <abc>

hi

--boundary-content
Content Type:application/octet-stream
Content-Disposition: attachment;filename=myfile
Content-ID: 2

...

--boundary-content

第一个 Content-Type 行之后的整个内容显示为单个纯文本附件。如何让浏览器说 hi 并提示下载包含 ... 内容的 myfile

I want to send a binary file to the user and have some HTML display on the browser. I'm using a CGI-BIN script with apache2. I found this example on page 4. The link also shows details about the multipart/related content-type. Here's what I tried so far:

Content-Type: Multipart/Related; boundary="boundary-content"; start=""; type=\"text/plain\""

--boundary-content
Content-Disposition: inline
Content Type:text/plain
Content-ID: <abc>

hi

--boundary-content
Content Type:application/octet-stream
Content-Disposition: attachment;filename=myfile
Content-ID: 2

...

--boundary-content

The whole thing after the first Content-Type line shows up as a single plaintext attachment. How can I make the browser say hi and prompt to download myfile with contents of ...?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

羁绊已千年 2024-09-21 13:18:03

我认为浏览器无法理解多部分 MIME 响应

i do not think browsers understand multipart MIME responses

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文