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

  • <small id='qsk98'></small><noframes id='qsk98'>

        <legend id='qsk98'><style id='qsk98'><dir id='qsk98'><q id='qsk98'></q></dir></style></legend>
      1. <tfoot id='qsk98'></tfoot>
      2. 创建用于即时下载的文本文件

        时间:2024-08-23

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

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

            <tbody id='SSF9g'></tbody>
          <legend id='SSF9g'><style id='SSF9g'><dir id='SSF9g'><q id='SSF9g'></q></dir></style></legend>
            <tfoot id='SSF9g'></tfoot>
                  <bdo id='SSF9g'></bdo><ul id='SSF9g'></ul>
                  本文介绍了创建用于即时下载的文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  更新 #1

                  下面发布的内容是为了让它输出文件.它所做的是输出字符串数据,然后是 HTML 表单的其余部分.有什么办法可以停止放入文件中的内容以及刚刚显示给浏览器的内容.

                  What has been posted below is spot on for getting it to output the file. What it is doing though is outputting the string data followed by the rest of the forms HTML. Is there any way to stop what is put into the file and what is just displayed to the browser.

                  更新 #2

                  刚刚添加 exit() 一切正常.谢谢!

                  Just added exit() and all works fine. Thanks!

                  EOU

                  我一直在环顾四周,看到了一些类似的东西,但并没有完全掌握我需要做什么才能完全完成任务.

                  I've been looking around and seen a few things similar but not quite fully got the grasp on what I need to do to achieve the task fully.

                  目前我有一个用户提供一些详细信息的表单.在提交时,它会被发布回自身并处理 POST 变量.我有一个预制的 HTML Web 模板,用于放置信息,只需执行 str_replace 就可以正常工作.

                  At the moment I have a form that a user supplies some details. On submit it is posted back to itself and the POST variables processed. I have a premade HTML web template for the information to be placed into which works fine and dandy just doing a str_replace.

                  我现在要做的是将其作为下载以纯文本文档的形式导出给用户.所以最终结果是用户点击表单上的提交,然后他们会打开一个下载弹出窗口,修改后的网页为 .txt 文件.

                  What I am trying to do now is export that as a download to the user in a plain text document. So the end result being the user clicks submit on the form and they then have a download popup open with the modified webpage as a .txt file.

                  据我了解,我需要使用 HTTPS 标头功能做一些事情.我不确定到底是什么才能实现我想要的.我只希望文件可以使用一次,但我认为它必须存储在最初的某个地方供用户下载,然后需要手动清理?

                  As far as I understand I need to do something using HTTPs headers functionality. What exactly though to achieve what I want I'm not sure. I only want the file to be available once, but I assume it has to be stored somewhere initally for the user to download which will then need cleaing up after manually?

                  任何帮助或积分都会很棒!谢谢.

                  Any help or points would be great! Thanks.

                  推荐答案

                  无需存储在任何地方.只需输出具有适当内容类型的内容即可.

                  No need to store it anywhere. Just output the content with the appropriate content type.

                  <?php
                      header('Content-type: text/plain');
                  ?>Hello, world.
                  

                  如果您希望触发下载提示,请添加内容处置.

                  Add content-disposition if you wish to trigger a download prompt.

                  header('Content-Disposition: attachment; filename="default-filename.txt"');
                  

                  这篇关于创建用于即时下载的文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:在 HTTP 标头中设置到期日期或最长期限 下一篇:PHP get_headers() 替代

                  相关文章

                • <legend id='I8GS7'><style id='I8GS7'><dir id='I8GS7'><q id='I8GS7'></q></dir></style></legend>
                    <bdo id='I8GS7'></bdo><ul id='I8GS7'></ul>

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

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

                    <tfoot id='I8GS7'></tfoot>