I am using PHP to download a number of files as zip folder, see code below, it shows me this error zipArchive::close() Read error: no such file or directory in C:// path
I have added HTML button on click to take the id of the row to download its files
if (isset($_GET['zip'])) {
$zip_id = $_GET['zip'];
  $query4 = "select f.id f.file_name, f.path, r.user_id from register r "
        . "join files f on f.register_id =r.user_id "
        . "where r.user_id=$zip_id";   
$result4 = mysqli_query($con, $query4);
if (($result4)) {
    while ($row = mysqli_fetch_array($result4)) {
        $document[$row['id']] = array(
            'id' => $row['id'],
            'file_name' => $row['file_name'],
            'path' => $row['path']
        );
    }
}
 // folder to load files  
if (extension_loaded('zip')) {
    // Checking ZIP extension is available  
    foreach($document as $f){
         $files[]='uploads/'.$f['path'];
    }
    if ($files != null) {
    // Checking files are selected  
        $zip = new ZipArchive(); // Load zip library   
        $zip_name = 'folder.zip';           // Zip name  
        if ($zip->open($zip_name, ZIPARCHIVE::CREATE) !== TRUE) {
            // Opening zip file to load files  
            $error .= "* Sorry ZIP creation failed at this time";
        }
        foreach ($files as $file){
        $zip->addFile($file,$file);} // Adding files into zip  
        $zip->close();
        if (file_exists($zip_name)) {
            // push to download the zip  
            header('Content-type: application/zip');
            header('Content-Disposition: attachment; filename="' . $zip_name . '"');
            readfile($zip_name);
            // remove zip file is exists in temp path  
            unlink($zip_name);
        }
    } else {
        $error .= "*  no file to zip ";
    }
} else {
    $error .= "* You dont have ZIP extension";
}
}
