0

ZipArchive doen't create archive at all!
I tried:

$zip = new ZipArchive($this->name, ZIPARCHIVE::CREATE); $zip = new ZipArchive($this->name, ZIPARCHIVE::OVERWRITE); $zip = new ZipArchive(); $zip->open($this->name, ZIPARCHIVE::CREATE); $zip = new ZipArchive(); $zip->open($this->name, ZIPARCHIVE::OVERWRITE); 

but all doesn't create an archive and return true!
If I try to creat file with fopen it normally works so it's not a permissions problem

Some ideas?

2
  • have you actually tried putting anything into this zip archive? I believe that until you actually attacha file to it, the zip file exists purely in memory only. Commented Nov 9, 2012 at 18:33
  • yes, i tried and addEmptyDir or addFile returns true too Commented Nov 9, 2012 at 18:35

1 Answer 1

3

Make sure to call $zip->close()

Also I can't recall if it creates the file if you don't add anything to it (your question doesn't say whether or not you did that).

Sign up to request clarification or add additional context in comments.

1 Comment

+1 It is very important to explicitly close writers/streams; in the case of a ZIP archive there is a checksum that must be added to the end which is why a close (read: "end adding files") is required.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.