[Typo3] VCD_archive - how to force download

Martin Rud rudi at rudekuvert.dk
Thu Mar 10 22:01:03 CET 2005


Hi

In another context I have made scriptthat does the work (se below). But 
now that I work with TYPO3 I hope it can work here too... :o)

(I guess that: header("Content-Type: application/force-download"); does 
the "job"...)


<------------- snippet ------------------------>
// Send the general header
if (eregi("IE 5",$HTTP_USER_AGENT)) { $msie5 = 1; }

header ("Expires: Mon, 10 Dec 2001 08:00:00 GMT");
header ("Last-Modified: " . gmdate ("D, d M Y H:i:s") . " GMT");
if ($HTTP_SERVER_VARS['HTTPS'] != 'on') {
   if($msie5){
      // IE cannot download from sessions without a cache
     header ('Cache-Control: public');
   } else {
     header ("Cache-Control: must-revalidate, post-check=0, pre-check=0");
     // header ("Cache-Control: no-cache, must-revalidate");
     header ("Pragma: no-cache");
   }
} else {
    // for SSL connections you have to replace the two previous lines with
    header ("Cache-Control: must-revalidate, post-check=0,pre-check=0");
    header ("Pragma: public");
}

header("Content-Type: application/force-download");
header ("Content-Length: " . filesize($file));
header ("Content-Disposition: attachment; filename=\"$filename\"");
readfile($file);
exit();

</---------------- snippet ------------------------>

Robert Markula wrote:
> Martin Rud wrote:
> 
>> Hi
>>
>> With my installation of VDC Archive some file types (pdf, for 
>> instance) opens inline (that is, in the browser window).
>>
>> I would like to avoid that.
>>
>> I prefer to make VCD force download (i.e. that the browser asks the 
>> user to "Save as" or "Open" the file). Is it possible to set VCD to 
>> force download when the user clicks on a file?
> 
> 
> I may be wrong, but as far as I know, this is a behaviour of the 
> webbrowser, not the webserver. The only way to force a download is 
> (again, as far as I know ;)) to zip the file or make some dirty filename 
> tricks (e.g. use abc.pdf_ instead of abc.pdf).
> 
> Hopefully somebody has better news...
> 
> Ro



More information about the TYPO3-english mailing list