0

I have a download script written in php which works fine BUT I've been running into problems allowing users to download .zip files of between 300 and 600mb from a hosted server. Files of around 70mb download fine but larger ones are either incomplete or corrupt. I've been reading that this problem could be caused by gzip being enabled on the server.

As the server is hosted I have no way of editng the apache config file to disable gzip. Is there another way? I've tried adding the code below to the .htaccess file that I created in the same directory as the php download script but it did not disable gzip.

#Disable GZIP in directory
RewriteRule ^(.*)$ $1 [NS,E=no-gzip:1,E=dont-vary:1]

What can I do to disable gzip?

This is what the repsonse headers are sending back when I try to download.

Cache-Control   max-age=604800
Connection  keep-alive
Content-Encoding    gzip
Content-Type    text/html; charset=UTF-8
Date    Tue, 13 Feb 2018 16:12:05 GMT
Expires Tue, 20 Feb 2018 16:12:05 GMT
Server  nginx/1.12.2
Transfer-Encoding   chunked
JulianJ
  • 1,259
  • 3
  • 22
  • 52
  • What is the main reason for files being corrupt? Does delivering them takes too long such that the PHP process is killed before it finishes serving the file? – Nico Haase Feb 13 '18 at 16:32
  • Yes, I think the files don't finish downloading reaching around 300-500mb after about 20 minutes. – JulianJ Feb 13 '18 at 16:34
  • 1
    You've tagged as PHP and mention Apache but it appears to be a question about Nginx... Can you please clarify that? – Álvaro González Feb 13 '18 at 16:35
  • I'm afraid I know very little about servers. I always assumed 'justhost' used an Apache server but indeed I can see nginx written in the reponse header. I can't help more I'm afraid. I suppose I could clarify with my host. – JulianJ Feb 13 '18 at 16:38
  • You can change the upload max size. See this one and lookup the answer with .user.ini https://stackoverflow.com/questions/1122418/changing-upload-max-filesize-on-php – Forbs Feb 13 '18 at 16:38
  • Can you provide links to these articles that claim this is a gzip problem? – Reactgular Feb 13 '18 at 16:38
  • http://www.media-division.com/the-right-way-to-handle-file-downloads-in-php/ – JulianJ Feb 13 '18 at 16:45
  • Here'a another article-http://www.heath-whyte.info/david/computers/corrupted-zip-file-downloads-with-php – JulianJ Feb 13 '18 at 16:58

0 Answers0