tim peterson
tim peterson

Reputation: 24305

Download zip file "Failed network error" (PHP/NGINX)

I'm getting the following error in my browser (Chrome & Firefox) when I attempt to download a zip file from my live server, https://mysite.com: Failed network error.

Confusingly, using the same code (below) from my live server on my localhost allows me to successfully download this same zip file:

$path=$data['path_new']='uploads/some-path/';
$file_name='test.zip';
$file=$path.$file_name;

header("Content-Disposition: attachment; filename=".$file_name);    
header("Content-Type: application/octet-stream");
readfile($file);

I'm using PHP and NGINX on both my localhost and live server with I believe the same configurations, but obviously something isn't right on my live site. Might someone help?

Upvotes: 5

Views: 3567

Answers (1)

nicolas
nicolas

Reputation: 719

I had exactly the same issue, zip file download with chrome not working on live server (HTTPS) but working with localhost. Similar code. Although I got rid of gzip encoding for the download page...

if (ini_get('zlib.output_compression'))
            ini_set('zlib.output_compression', 'Off');

... I still got "Content-Encoding: gzip" in response headers. I finally added that (I know it's a bit lousy):

header_remove('Content-Encoding');

And apart from a security warning concerning zip extension it's working for me. Probably late for you, hope this can help someone.

Bye

Upvotes: 2

Related Questions