How to create empty zip archiving in php

how to create an empty php zip archive something like new → zip archive

+4
source share
2 answers

You were pretty close:

$zip = new ZipArchive(); $zip->open('my-archive.zip', ZipArchive::CREATE); // To actually save the archive you have to put some file/dir into it $zip->addFromString('tmp', ''); $zip->close(); 

You can learn more about the PHP manual pages .

+8
source

Creation of '.' works for me:

 $zip->addEmptyDir('.'); 

It appears in some applications when listing files in ZIP, but not when extracting it.

+3
source

All Articles