[英]Large Zip file offered for download using php
我使用的代码下载如下..
ob_start();
ini_set('memory_limit','1200M');
set_time_limit(900);
// required for IE, otherwise Content-disposition is ignored
if(ini_get('zlib.output_compression'))
ini_set('zlib.output_compression', 'Off');
apache_setenv('no-gzip', '1');
$filename = "test.zip";
$filepath = "http://demo.com/";
// http headers for zip downloads
header('Content-Description: File Transfer');
header('Content-Transfer-Encoding: binary');
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=\"".$filename."\"");
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize($filepath.$filename));
//set_time_limit(0);
ob_clean();
flush();
readfile($filepath.$filename);
exit;
我的文件大小是 100MB zip 文件。 仅下载 45MB 到 50MB。 我不知道问题出在哪里。 请帮我...
ob_clean
丢弃 output 缓冲区的当前内容,但不会禁用它。 所以readfile
的output缓冲在memory中,受php的memory_limit
指令限制。
相反,使用ob_end_clean
丢弃和禁用 output 缓冲区,或者根本不使用 output 缓冲。
这可能无法解决您的所有问题,但是我看到以下内容:
ob_start();
和ob_clean();
命令。 请注意,后者不会破坏 output 缓冲区。//set_time_limit(0);
以免遇到时间限制问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.