[英]Large Zip file offered for download using php
I used code for downloading as follows..我使用的代码下载如下..
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;
my file size is 100MB zip file.我的文件大小是 100MB zip 文件。 Only downloading 45MB to 50MB.
仅下载 45MB 到 50MB。 I dont no where is the problem.
我不知道问题出在哪里。 please help me...
请帮我...
ob_clean
discards the current content of the output buffer, but does not disable it. ob_clean
丢弃 output 缓冲区的当前内容,但不会禁用它。 Therefore, the output of readfile
is buffered in memory, which is limited by php's memory_limit
directive.所以
readfile
的output缓冲在memory中,受php的memory_limit
指令限制。
Instead, use ob_end_clean
to discard and disable the output buffer, or don't use output buffering at all.相反,使用
ob_end_clean
丢弃和禁用 output 缓冲区,或者根本不使用 output 缓冲。
This might not solve all your problems, however I see the following:这可能无法解决您的所有问题,但是我看到以下内容:
ob_start();
ob_start();
and ob_clean();
ob_clean();
commands.//set_time_limit(0);
//set_time_limit(0);
to not run into time limit problems.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.