create download file in system tmp, better error checking (Closes: #487)

This commit is contained in:
Uwe Steinmann 2020-09-04 09:43:18 +02:00
parent 01062a16a5
commit 4c64b316db

View File

@ -46,16 +46,18 @@ class SeedDMS_Controller_TransmittalDownload extends SeedDMS_Controller_Common {
} }
} }
$filename = tempnam('/tmp', ''); $filename = tempnam(sys_get_temp_dir(), 'transmittal-download');
$downmgr->createArchive($filename); if($filename) {
header("Content-Transfer-Encoding: binary"); $downmgr->createArchive($filename);
header("Content-Length: " . filesize($filename)); header("Content-Transfer-Encoding: binary");
header("Content-Disposition: attachment; filename=\"export-" .date('Y-m-d') . ".zip\""); header("Content-Length: " . filesize($filename));
header("Content-Type: application/zip"); header("Content-Disposition: attachment; filename=\"export-" .date('Y-m-d') . ".zip\"");
header("Cache-Control: must-revalidate"); header("Content-Type: application/zip");
header("Cache-Control: must-revalidate");
readfile($filename); readfile($filename);
unlink($filename); unlink($filename);
}
exit; exit;
} }
} }