<tfoot id='FSQg4'></tfoot>

  1. <legend id='FSQg4'><style id='FSQg4'><dir id='FSQg4'><q id='FSQg4'></q></dir></style></legend>
      <bdo id='FSQg4'></bdo><ul id='FSQg4'></ul>

    1. <i id='FSQg4'><tr id='FSQg4'><dt id='FSQg4'><q id='FSQg4'><span id='FSQg4'><b id='FSQg4'><form id='FSQg4'><ins id='FSQg4'></ins><ul id='FSQg4'></ul><sub id='FSQg4'></sub></form><legend id='FSQg4'></legend><bdo id='FSQg4'><pre id='FSQg4'><center id='FSQg4'></center></pre></bdo></b><th id='FSQg4'></th></span></q></dt></tr></i><div id='FSQg4'><tfoot id='FSQg4'></tfoot><dl id='FSQg4'><fieldset id='FSQg4'></fieldset></dl></div>

      <small id='FSQg4'></small><noframes id='FSQg4'>

      带有 302 重定向的内容处置

      Content-Disposition with 302 redirect(带有 302 重定向的内容处置)
    2. <tfoot id='U6b7O'></tfoot>

      <small id='U6b7O'></small><noframes id='U6b7O'>

      <legend id='U6b7O'><style id='U6b7O'><dir id='U6b7O'><q id='U6b7O'></q></dir></style></legend>

      1. <i id='U6b7O'><tr id='U6b7O'><dt id='U6b7O'><q id='U6b7O'><span id='U6b7O'><b id='U6b7O'><form id='U6b7O'><ins id='U6b7O'></ins><ul id='U6b7O'></ul><sub id='U6b7O'></sub></form><legend id='U6b7O'></legend><bdo id='U6b7O'><pre id='U6b7O'><center id='U6b7O'></center></pre></bdo></b><th id='U6b7O'></th></span></q></dt></tr></i><div id='U6b7O'><tfoot id='U6b7O'></tfoot><dl id='U6b7O'><fieldset id='U6b7O'></fieldset></dl></div>
            <bdo id='U6b7O'></bdo><ul id='U6b7O'></ul>

                  <tbody id='U6b7O'></tbody>
                本文介绍了带有 302 重定向的内容处置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                这是昨晚工作的,但我一定是不小心改变了一些东西,因为现在不是.

                This was working last night, but I must have accidentally changed something, because it isn't now.

                从这些标题中应该清楚我想要做什么:

                What I am trying to do should be clear from these headers:

                Content-Disposition: attachment;filename=english_customizable.xml
                Location: http://tortoisewrath.com/files/2.xml
                

                但是,当发送此标头时,Content-Disposition 部分在重定向后不起作用.

                However, when this header is sent, the Content-Disposition part doesn't work after the redirect.

                ...为什么?

                推荐答案

                你试图做的是不明智的检查这个问题;标头位置 + 内容处置

                What you're trying to do is inadvisable check this question; Header Location + Content Disposition

                Content-Disposition + Location 标头

                但是您可以做到,要使其正常工作,您必须在发送之前缓冲整个响应.您可以通过输出缓冲来做到这一点

                But you can do it, to make it work you will have to buffer your whole response before sending it. You can do this with output buffering

                • http://php.net/manual/en/book.outcontrol.php

                否则浏览器可能会在下载文件之前解释 Location 标头.无论哪种方式都很粗略,所以你不应该这样做.

                Else the browser may interpret the Location header before the file is downloaded. It's sketchy either way, so you shouldn't want to do this.

                请注意使用 Content-Disposition: attachment; 强制另存为"将确保客户端不会去/导航任何地方,所以下面的方法无论如何,它自己应该没问题.

                Please note that forcing 'save as' using Content-Disposition: attachment; will make sure the client doesn't go/navigate anywhere, so the method below on its own should be fine in any case.

                在 php 中流式传输文件

                仅引用 一个聪明的人:

                // To use header() with 'content-type', why don't you use mime_content_type() function rather than checking the type on the basis of extension? 
                // Example code: 
                
                <?php 
                $file="test.docx"; 
                header("Pragma: public"); 
                header('Content-disposition: attachment; filename='.$file); 
                header("Content-type: ".mime_content_type($file)); 
                header('Content-Encoding: identity'); 
                ob_clean(); 
                flush(); 
                readfile($file); 
                ?> 
                
                // Use $file to map to whichever type of file. 
                // Note: the mime types should already be defined in apache settings
                

                来源:http://www.php.net/manual/zh/function.header.php#107581

                请注意,原始答案使用了 HTTP 中实际上不存在的 Content-Transfer-Encoding.该来源下方的评论对此进行了解释:http://www.php.net/manual/en/function.header.php#107044

                Note that the original answer used Content-Transfer-Encoding which doesn't actually exist in HTTP. The comment below that source explains it: http://www.php.net/manual/en/function.header.php#107044

                这篇关于带有 302 重定向的内容处置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)

                • <legend id='COsd7'><style id='COsd7'><dir id='COsd7'><q id='COsd7'></q></dir></style></legend>

                      • <bdo id='COsd7'></bdo><ul id='COsd7'></ul>
                        1. <small id='COsd7'></small><noframes id='COsd7'>

                          <tfoot id='COsd7'></tfoot>
                          <i id='COsd7'><tr id='COsd7'><dt id='COsd7'><q id='COsd7'><span id='COsd7'><b id='COsd7'><form id='COsd7'><ins id='COsd7'></ins><ul id='COsd7'></ul><sub id='COsd7'></sub></form><legend id='COsd7'></legend><bdo id='COsd7'><pre id='COsd7'><center id='COsd7'></center></pre></bdo></b><th id='COsd7'></th></span></q></dt></tr></i><div id='COsd7'><tfoot id='COsd7'></tfoot><dl id='COsd7'><fieldset id='COsd7'></fieldset></dl></div>
                            <tbody id='COsd7'></tbody>