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

        <bdo id='0Tr3w'></bdo><ul id='0Tr3w'></ul>
      1. <small id='0Tr3w'></small><noframes id='0Tr3w'>

      2. 使用 php 下载文件,而不是处理大文件?

        using php to download files, not working on large files?(使用 php 下载文件,而不是处理大文件?)
        • <i id='8nu6U'><tr id='8nu6U'><dt id='8nu6U'><q id='8nu6U'><span id='8nu6U'><b id='8nu6U'><form id='8nu6U'><ins id='8nu6U'></ins><ul id='8nu6U'></ul><sub id='8nu6U'></sub></form><legend id='8nu6U'></legend><bdo id='8nu6U'><pre id='8nu6U'><center id='8nu6U'></center></pre></bdo></b><th id='8nu6U'></th></span></q></dt></tr></i><div id='8nu6U'><tfoot id='8nu6U'></tfoot><dl id='8nu6U'><fieldset id='8nu6U'></fieldset></dl></div>

          <small id='8nu6U'></small><noframes id='8nu6U'>

          • <bdo id='8nu6U'></bdo><ul id='8nu6U'></ul>

                <tfoot id='8nu6U'></tfoot>
              1. <legend id='8nu6U'><style id='8nu6U'><dir id='8nu6U'><q id='8nu6U'></q></dir></style></legend>
                  <tbody id='8nu6U'></tbody>
                  本文介绍了使用 php 下载文件,而不是处理大文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我使用 php 下载文件,而不是文件本身在新窗口中打开.它似乎适用于较小的文件,但不适用于大文件(我需要它来处理非常大的文件).这是我必须下载文件的代码:

                  I'm using php to download files, rather than the file itself opening in a new window. It seems to work ok for smaller files, but does not work for large files (I need this to work on very large files). Here's the code I have to download the file:

                  function downloadFile($file) {   
                      if (file_exists($file)) {         
                          //download file
                          header('Content-Description: File Transfer');
                          header('Content-Type: application/octet-stream');
                          header('Content-Disposition: attachment; filename='.basename($file));
                          header('Content-Transfer-Encoding: binary');
                          header('Expires: 0');
                          header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
                          header('Pragma: public');
                          header('Content-Length: '.filesize($file));
                          ob_clean();
                          flush();
                          readfile($file);
                          exit;   
                      };    
                  };
                  

                  但是当我尝试下载一个大文件(例如 265mb)时,浏览器告诉我它找不到该文件?这些文件肯定在服务器上,并且该脚本适用于较小的文件.有没有办法下载类似于我已有的大文件?

                  But when I try to download a large file (example 265mb) the browser tells me that it can't find the file? The files are definately on the server, and the script works fine for the smaller files. Is there any way of downloading large files similar to what I already have?

                  推荐答案

                  PHP 对脚本可以运行的时间和可以使用的内存量有限制.脚本可能在它完成之前就超时了,或者因为读入大文件而占用了太多内存.

                  PHP has limits on how long a script can run, and how much memory it can use. It's possible that the script is timing out before it has completed, or is using up too much memory by reading in the large file.

                  尝试调整 max_execution_timememory_limit php.ini 中的变量.如果您无权访问 php.ini,请尝试使用 set_time_limit 和/或 ini_set 函数.

                  Try tweaking the max_execution_time and memory_limit variables in php.ini. If you don't have access to php.ini, try the set_time_limit and/or ini_set functions.

                  这篇关于使用 php 下载文件,而不是处理大文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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 的问题)
                    <bdo id='Qrhbt'></bdo><ul id='Qrhbt'></ul>

                      <tfoot id='Qrhbt'></tfoot>

                      <legend id='Qrhbt'><style id='Qrhbt'><dir id='Qrhbt'><q id='Qrhbt'></q></dir></style></legend>
                        <tbody id='Qrhbt'></tbody>
                    1. <small id='Qrhbt'></small><noframes id='Qrhbt'>

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