I am a severe novice, but I did quite a lot of research before posting, so I hope you can help.
I'm trying to serve a large .zip file that is hosted on an Apache server, about 6.4 Gb. The file shows complete download in browser, but in fact only about 500Mb have been downloaded. This seems like a very common problem and have found a lot of other posts and information on the web, but the problem has been persistent for me.
Large Zip file offered for download using php
IE download incomplete even though it claims success
Large zip downloads failing only in IE
I have been testing with Chrome 39.0.2171.71, but I get the same problem with FireFox and IE. I think my file is much larger than what others have been posting about, therefore perhaps their solutions helped the situation, but didn't fix the root problem. I have a second .zip file that is about 400Mb, and I use the same http headers with success.
The most useful article I have found is this: http://perishablepress.com/http-headers-file-downloads/ and I have copied much of the php shown below from that source, as it appears other posters on this website have done.
I have also tried using X-SendFile, but I don't think my webhost has the appropriate Apache module installed. I've spent all day working on this, and have run out of ideas! I have used a download manager with success, I don't know if this was just by chance or what, but I don't want to require my clients to have to download and install a separate program just to get the .zip file.
<?php
// HTTP Headers for ZIP File Downloads
// set example variables
$filename = "huge.zip";
$filepath = "****";
// http headers for zip downloads
// header("X-Sendfile: $filepath$filename");
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_end_flush();
@readfile($filepath.$filename);
?>
Here are the response headers when I run the php above
Remote Address:76.162.142.242 Request URL:****/GetSW.php Request Method:GET Status Code:200 OK Request Headers Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 Accept-Encoding:gzip, deflate, sdch Accept-Language:en-US,en;q=0.8 Authorization:Basic ****** Connection:keep-alive Cookie:_ga=GA1.2.1176828605.1417985823 DNT:1 Host:www.teamursa.org Referer:http://www.teamursa.org/****.html User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36 Response Headers Cache-Control:public Connection:Keep-Alive Content-Description:File Transfer Content-Disposition:attachment; filename="huge.zip" Content-Length:6720560824 Content-Transfer-Encoding:binary Content-Type:application/octet-stream Date:Sun, 07 Dec 2014 22:16:57 GMT Expires:0 Keep-Alive:timeout=3, max=120 Pragma:public Server:Apache X-Powered-By:PHP/5.2.17
You might need to increase the memory limit on the server. Try the below just after the opening PHP tag
ini_set('memory_limit','16M');
And just keep increasing from 16M
I recommend you try using a web browser to download file directly, meaning you go to the address that file is stored at. Eg www.example.com/downloads/download.zip Hope this helps
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.