From bdcf4c153ff7bc5fc18dd828bc3d12519b7c719c Mon Sep 17 00:00:00 2001 From: =?utf8?q?St=C3=A9phane=20Jacob?= Date: Mon, 3 Oct 2011 22:01:17 +0200 Subject: [PATCH] Allows to set file name in headers. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Jacob --- include/platal.inc.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/platal.inc.php b/include/platal.inc.php index f9bf127..6b28abb 100644 --- a/include/platal.inc.php +++ b/include/platal.inc.php @@ -261,7 +261,7 @@ function pl_content_headers($content_type, $encoding = 'utf-8') * cache duration defaults to the global static_cache_duration. No encoding is * applied by default. */ -function pl_cached_content_headers($content_type, $encoding = null, $cache_duration = -1) +function pl_cached_content_headers($content_type, $encoding = null, $cache_duration = -1, $filename = null) { global $globals; $cache_duration = ($cache_duration < 0 ? $globals->static_cache_duration : $cache_duration); @@ -270,6 +270,9 @@ function pl_cached_content_headers($content_type, $encoding = null, $cache_durat header("Expires: " . gmdate('D, d M Y H:i:s', time() + $cache_duration) . " GMT"); header("Pragma: "); pl_content_headers($content_type, $encoding); + if (!is_null($filename)) { + header('Content-Disposition: attachment; filename=' . $filename); + } } /** -- 2.1.4