<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 下载文件,而不是处理大文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  Is PHP or PHP based web framework stateful or stateless?(PHP 或基于 PHP 的 Web 框架是有状态的还是无状态的?)
                  How to parse django style template tags(如何解析 django 样式模板标签)
                  What is a good setup for editing PHP in Emacs?(在 Emacs 中编辑 PHP 的好设置是什么?)
                  How to check whether specified PID is currently running without invoking ps from PHP?(如何在不从 PHP 调用 ps 的情况下检查指定的 PID 当前是否正在运行?)
                  What#39;s the difference between escapeshellarg and escapeshellcmd?(escapeshellarg 和escapeshellcmd 有什么区别?)
                  php in background exec() function(php 后台 exec() 函数)
                    <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>