getUploadsFilePath(); if (!file_exists($log_path . $filename)) { http_response_code(400); return; } $log_contents = file_get_contents($log_path . $filename); $zipfilename = "wpsynchro_db_backup_" . $job_id . ".zip"; http_response_code(200); // IIS fails if this is not here header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: public"); header("Content-Description: File Transfer"); header("Content-Type: application/zip"); header("Content-Disposition: attachment; filename=" . $zipfilename); $zipfile = tempnam($log_path, "zip"); $zip = new \ZipArchive(); $zip->open($zipfile, \ZipArchive::OVERWRITE); $zip->addFromString($filename, $log_contents); $zip->close(); readfile($zipfile); unlink($zipfile); exit(); } }