API: Content-Disposition:attachment Header für Download-Parameter
All checks were successful
Deploy bericht / deploy (push) Has been skipped

This commit is contained in:
Eduard Wisch 2026-04-17 12:56:16 +02:00
parent 641e16a2bc
commit e46b2907f2

View file

@ -106,10 +106,15 @@ if ($size === 'small' || $size === 'mini') {
}
$mime = function_exists('dol_mimetype') ? dol_mimetype($full) : 'application/octet-stream';
$download = !empty($_GET['download']);
$filename = $download ? basename($full) : '';
header('Content-Type: '.$mime);
header('Content-Length: '.filesize($full));
header('Cache-Control: private, max-age=3600');
header('Access-Control-Allow-Origin: *');
if ($download) {
header('Content-Disposition: attachment; filename="'.addslashes($filename).'"');
}
readfile($full);
exit;