Error downloading zip from PHP

3

Good!

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; filename=fotos.zip');
   header('Content-Transfer-Encoding: binary');
   header('Content-Length: '.filesize('C:/ExportacionImagenes/CarpetaComprimida.zip'));

   readfile('C:/ExportacionImagenes/CarpetaComprimida.zip');
    
asked by Luis Pavez 27.09.2016 в 16:04
source

2 answers

4

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
source
1

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