سؤال

I am generating a zip file using zip archive and sending it to the browser for the user to download.

$archive_file_name = "/var/www/html/administrator/1396413991.zip";
header("Content-type: application/zip"); 
header("Content-Disposition: attachment; filename=test.zip"); 
header("Expires: on, 01 Jan 1970 00:00:00 GMT"); 
header("Pragma: no-cache"); 
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
readfile("$archive_file_name");
exit;

My download stops at 11Mb and i am unable to download files more than 11mb, What iam doing wrong or incorrect in this.

Any suggestion would be appreciated. Thanks.

هل كانت مفيدة؟

المحلول

I would advice in using fpassthru instead, it's been made specifically for this situation.

Note: 

Passthru didn't work for me for files greater than about 5Mb. Just adding "ob_end_clean()", all works fine now, including > 50Mb files.

$ToProtectedFile=$pathUnder.$filename
$handle = @fopen($ToProtectedFile, "rb");

@header("Cache-Control: no-cache, must-revalidate");
@header("Pragma: no-cache"); //keeps ie happy
@header("Content-Disposition: attachment; filename= ".$NomFichier);
@header("Content-type: application/octet-stream");
@header("Content-Length: ".$SizeOfFile);
@header('Content-Transfer-Encoding: binary');

ob_end_clean();//required here or large files will not work
@fpassthru($handle);//works fine now

نصائح أخرى

May be you can try and change your php.ini settings to

memory_limit = 128M
post_max_size = 300M
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top