Skip to content
Advertisement

Download PHP ZipArchive returns corrupt, blank zip file

I’ve had a look at various threads about ZipArchive and how to get files to download. However, I’ve gotten a bit stuck here. I currently have a form that looks like this

JavaScript

Within that form, are some aspects that come from the rest of the script, which is here:

JavaScript

I’ve tested all of the other bits, like the generation of the objects and such. But currently I’m just puzzled at why the files won’t download properly. Whenever I hit the submit button to download, after selecting one or two of the items, I get given a zip file with the correct zip name – all fine and dandy. But when attempting to open the file using WinRaR, the following message appears:

The archive is either in unknown format or damaged

I have attempted the old trick of opening the zip file in notepad to try and see whether there are any errors present. However, the result that returns is completely blank, which is really weird to me.

Does anyone know how I might fix this? Thanks in advance

Advertisement

Answer

Solved: Needed to create a temp folder, and store them there. Here’s the final solution:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement