提供使用php下载的大型Zip文件
我使用的代码下载如下提供使用php下载的大型Zip文件,php,download,zip,Php,Download,Zip,我使用的代码下载如下 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');
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
丢弃输出缓冲区的当前内容,但不禁用它。因此,readfile
的输出缓冲在内存中,这受到php指令的限制
相反,使用可放弃和禁用输出缓冲区,或者根本不使用输出缓冲。这可能无法解决所有问题,但我看到以下情况:
ob_start()代码>和ob_clean()代码>命令。注意后者
//设置时间限制(0)代码>以避免遇到时间限制问题
嗨,你能解决这个问题吗?