Allows to set file name in headers.
authorStéphane Jacob <sj@m4x.org>
Mon, 3 Oct 2011 20:01:17 +0000 (22:01 +0200)
committerStéphane Jacob <sj@m4x.org>
Mon, 3 Oct 2011 20:02:10 +0000 (22:02 +0200)
Signed-off-by: Stéphane Jacob <sj@m4x.org>
include/platal.inc.php

index f9bf127..6b28abb 100644 (file)
@@ -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);
+    }
 }
 
 /**