API: Content-Disposition:attachment Header für Download-Parameter
All checks were successful
Deploy bericht / deploy (push) Has been skipped
All checks were successful
Deploy bericht / deploy (push) Has been skipped
This commit is contained in:
parent
641e16a2bc
commit
e46b2907f2
1 changed files with 5 additions and 0 deletions
|
|
@ -106,10 +106,15 @@ if ($size === 'small' || $size === 'mini') {
|
||||||
}
|
}
|
||||||
|
|
||||||
$mime = function_exists('dol_mimetype') ? dol_mimetype($full) : 'application/octet-stream';
|
$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-Type: '.$mime);
|
||||||
header('Content-Length: '.filesize($full));
|
header('Content-Length: '.filesize($full));
|
||||||
header('Cache-Control: private, max-age=3600');
|
header('Cache-Control: private, max-age=3600');
|
||||||
header('Access-Control-Allow-Origin: *');
|
header('Access-Control-Allow-Origin: *');
|
||||||
|
if ($download) {
|
||||||
|
header('Content-Disposition: attachment; filename="'.addslashes($filename).'"');
|
||||||
|
}
|
||||||
readfile($full);
|
readfile($full);
|
||||||
exit;
|
exit;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue