diff --git a/inc/fetch.functions.php b/inc/fetch.functions.php index 207ad9e5face6ba2a18bd35bef5c530f930beed4..3eacaa2fe4aea3509e61c10de1719fa279fccca0 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 diff --git a/lib/exe/fetch.php b/lib/exe/fetch.php index f33b3f2f8cb0dee972ad6475ee1e2b944646a85a..5f82ad0e0cd683adc26dd707f4bcb93547f5af81 100644 --- a/lib/exe/fetch.php +++ b/lib/exe/fetch.php @@ -89,7 +89,7 @@ if (defined('SIMPLE_TEST')) { // finally send the file to the client $evt = new Doku_Event('MEDIA_SENDFILE', $data); if($evt->advise_before()) { - sendFile($data['file'], $data['mime'], $data['download'], $data['cache'], $data['ispublic']); + sendFile($data['file'], $data['mime'], $data['download'], $data['cache'], $data['ispublic'], $data['orig']); } // Do something after the download finished. $evt->advise_after(); // will not be emitted on 304 or x-sendfile