[TYPO3-dev] Filename of the image after resize.
Jigal van Hemert
jigal at xs4all.nl
Tue May 26 11:34:47 CEST 2009
>> The link for the various sizes will not be the actual filename, but a
>> call
>> to the TYPO3 page with the right piVars that will force a download.
>>
>> Works like a charm!
>
> Yes, I consider this I think that's good idea. first I need to make some
> test :)
This is the function to provide "force download" headers which I've been
using for years now. I haven't tested it with IE8 yet...
/**
* Sends out the necessary headers to force a download in various browsers
*
* @param string file name for download client
* @param string mimetype
* @return -
*/
protected function DLHeader ($disp_filename, $filetype) {
// handle disposition
$disp_attach = true;
$disp_attach_txt="attachment";
$disp_filename=ereg_replace('[^-a-zA-Z0-9\.]','_',$disp_filename);
$cont_filename=$disp_filename;
// figure out internet explorer version for quirks below
$isIE=((preg_match('/compatible;
MSIE(\d*)/',$_SERVER['HTTP_USER_AGENT'],$matches)) &&
(strpos($_SERVER['HTTP_USER_AGENT'],'Opera')===false));
$isIE6=(($isIE) && ($matches[1]>5));
// filename should be quoted unless we're attaching on pre-IE6
if ((!$disp_attach) || (($disp_attach) && ((!$isIE) || ($isIE6))))
$disp_filename="\"".$disp_filename."\"";
// determine content-type
// modify this for serving local files
if (!$disp_attach) $cont_type=$filetype;
elseif (($isIE) && (!$isIE6)) $cont_type="application/download";
else $cont_type="application/octet-stream";
// set headers
// Output the headers for last-modified en content-length;
// We extract these from the http headers we harvested from a check on
the fileserver
// modify this for serving local files
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Content-Disposition: ".$disp_attach_txt.";
filename=".$disp_filename.";");
header("Content-Type: ".$cont_type."; name=\"".$cont_filename."\";");
return(true);
}
--
Jigal van Hemert.
More information about the TYPO3-dev
mailing list