PHP creating and downloading zip, no error but doesn't work : <pre><code>function downloadZipFunction() {
    echo 'entered downloadzipfunction';
    //$files = $myArray;
    global $files;
    print_r($files); echo 'plis rch here';
    # create new zip opbject
    $zip = new ZipArchive();
    echo "before tempnam";
    # create a temp file &amp; open it
    $tmp_file = tempnam('./docs/','tmp');
    echo "after tempnam";
    echo $tmp_file;
    $zip-&gt;open($tmp_file, ZipArchive::CREATE);

    # loop through each file
    foreach($files as $file){
        echo "entered foreach";
        # download file
        $download_file = file_get_contents("docs/".$file);
        echo "docs/".$file;
        #add it to the zip
        $zip-&gt;addFromString(basename($file),$download_file);
        echo basename($file);
    }

    # close zip
    $zip-&gt;close();

    # send the file to the browser as a download
    header('Content-disposition: attachment; filename= docs_$prop.zip');
    header('Content-type: application/zip');
    readfile($tmp_file);
    echo $tmp_file;
    //unlink($tmp_file);
}
</code></pre>

<p>It outputs 'entered downloadzipfunctionArray ( [0] => 1514223591754.xml ) plis rch here' but nothing else after that, no error.
No file is created on the server as well.</p>
