diff --git a/api/photo.php b/api/photo.php index 054901d..e8ddb75 100644 --- a/api/photo.php +++ b/api/photo.php @@ -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;