summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorknut <>2006-12-04 13:00:52 +0000
committerknut <>2006-12-04 13:00:52 +0000
commit07edf7e8f1aa230d2da2a41db1b0c718ccc53bc9 (patch)
treecb586ed47087676b6e93bf40d4e5bbfb7f57a59b /framework
parent9344b8be5dde09c8d4d3296368d2bb29a18e85e0 (diff)
fixed #478
Diffstat (limited to 'framework')
-rw-r--r--framework/Web/THttpResponse.php9
1 files changed, 6 insertions, 3 deletions
diff --git a/framework/Web/THttpResponse.php b/framework/Web/THttpResponse.php
index a7a949f0..45337add 100644
--- a/framework/Web/THttpResponse.php
+++ b/framework/Web/THttpResponse.php
@@ -225,9 +225,10 @@ class THttpResponse extends TModule implements ITextWriter
* @param string content to be set. If null, the content will be read from the server file pointed to by $fileName.
* @param string mime type of the content.
* @param array list of headers to be sent
+ * @param string alternative file name used in attachment disposition
* @throws TInvalidDataValueException if the file cannot be found
*/
- public function writeFile($fileName,$content=null,$mimeType=null,$headers=null)
+ public function writeFile($fileName,$content=null,$mimeType=null,$headers=null,$displayName=null)
{
static $defaultMimeTypes=array(
'css'=>'text/css',
@@ -251,7 +252,6 @@ class THttpResponse extends TModule implements ITextWriter
$mimeType=$defaultMimeTypes[$ext];
}
}
- $fn=basename($fileName);
if(is_array($headers))
{
foreach($headers as $h)
@@ -265,7 +265,10 @@ class THttpResponse extends TModule implements ITextWriter
}
header("Content-type: $mimeType");
header('Content-Length: '.($content===null?filesize($fileName):strlen($content)));
- header("Content-Disposition: attachment; filename=\"$fn\"");
+ if($displayName === null) {
+ $displayName = basename($fileName);
+ }
+ header("Content-Disposition: attachment; filename=\"$displayName\"");
header('Content-Transfer-Encoding: binary');
if($content===null)
readfile($fileName);