Creating Zip Files with PHP – Windows says the files are empty

  7zip, php, windows, zip

I am creating a zip file in PHP using the following:

$zipfilename = "/";
$mp3path = "/path/to/mp3-files/";

if(!is_file($zipfilename)) {
    $zip = new ZipArchive();
    if ($zip->open($zipfilename, ZipArchive::CREATE) !== TRUE) {
        echo("cannot open <$filename>n");
    } else { 

        foreach($mp3Album as $a) {
            if(is_file($mp3path.$a['file'])) {


The zip gets created, however when I download it and double click to view it in Windows 10, it states this folder is empty.

If I right click and select ‘Extract All..’ and try and extract it, I get the message: The file is invalid.

However 7Zip will extract it no problem.

What am I doing wrong that windows cannot handle this file?

Source: Windows Questions