diff options
author | Andreas Gohr <andi@splitbrain.org> | 2014-02-02 11:45:29 -0800 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2014-02-02 11:45:29 -0800 |
commit | c67778ecfe740d58c893edeaca1a764b62b63208 (patch) | |
tree | abe9f854f22e5778579dc4e368eb924c5bd1dda2 /inc/fetch.functions.php | |
parent | 9585623da6462d613fea9809128d1153adfe573d (diff) | |
parent | 2fd6745d5fd3a6b5b4b5a0a1952826095e35dac7 (diff) | |
download | rpg-c67778ecfe740d58c893edeaca1a764b62b63208.tar.gz rpg-c67778ecfe740d58c893edeaca1a764b62b63208.tar.bz2 |
Merge pull request #517 from gamma/master
Add the original filename to sendFile for Content-Disposition
Diffstat (limited to 'inc/fetch.functions.php')
-rw-r--r-- | inc/fetch.functions.php | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/inc/fetch.functions.php b/inc/fetch.functions.php index 207ad9e5f..3eacaa2fe 100644 --- a/inc/fetch.functions.php +++ b/inc/fetch.functions.php @@ -15,13 +15,15 @@ * * @author Andreas Gohr <andi@splitbrain.org> * @author Ben Coburn <btcoburn@silicodon.net> + * @author Gerry Weissbach <dokuwiki@gammaproduction.de> * @param string $file local file to send * @param string $mime mime type of the file * @param bool $dl set to true to force a browser download * @param int $cache remaining cache time in seconds (-1 for $conf['cache'], 0 for no-cache) * @param bool $public is this a public ressource or a private one? + * @param string $orig original file to send - the file name will be used for the Content-Disposition */ -function sendFile($file, $mime, $dl, $cache, $public = false) { +function sendFile($file, $mime, $dl, $cache, $public = false, $orig = null) { global $conf; // send mime headers header("Content-Type: $mime"); @@ -62,11 +64,16 @@ function sendFile($file, $mime, $dl, $cache, $public = false) { $fmtime = @filemtime($file); http_conditionalRequest($fmtime); + // Use the current $file if is $orig is not set. + if ( $orig == null ) { + $orig = $file; + } + //download or display? if($dl) { - header('Content-Disposition: attachment; filename="'.utf8_basename($file).'";'); + header('Content-Disposition: attachment; filename="'.utf8_basename($orig).'";'); } else { - header('Content-Disposition: inline; filename="'.utf8_basename($file).'";'); + header('Content-Disposition: inline; filename="'.utf8_basename($orig).'";'); } //use x-sendfile header to pass the delivery to compatible webservers |