Error downloading zip from PHP



I'm trying to make a download of a zip file from the server, but when I start the download, it gets stuck ending up as failed.

- As a data, when I change the file type to plain and download a txt any, download and open without problems -

I leave part of my code where I trigger the download. (I changed the names so that my problem is understood)

   header('Content-Type: application/zip');
   header('Content-Disposition: attachment;');
   header('Content-Transfer-Encoding: binary');
   header('Content-Length: '.filesize('C:/ExportacionImagenes/'));

asked by Luis Pavez 27.09.2016 в 16:04

2 answers


I can not comment, so I put it as an answer.

The change you have made to memory_limit will have a more or less large effect depending on where you have done it. This value determines the maximum amount of memory that a script can use. If the value has changed in the php.ini file of your server, then it will affect all the php scripts of the same, so if there are many simultaneous requests, the memory can be exhausted quickly if the scripts use a lot of memory. If the value you have changed in the script itself (using ini_set) will only affect the script itself.

I usually leave a relatively small value in the server configuration, and only increase using ini_set in those scripts that need it.

answered by 27.09.2016 / 20:21

Finally I solved it by modifying the memory_limit . It was in 128M and I uploaded it to 1280M and download without problems. I do not know what are the disadvantages of having modified that value.

answered by 27.09.2016 в 19:07