rendered paste bodyfunction downloadFile( $FileName, $File ) {
if( ! file_exists( $File ) ) {
print( "File $File does not exist\n" );
return ;
}
if( preg_match( "/.pdf/", $FileName ) ) {
$Mime = "application/pdf";
} else {
$Mime = "application/octet-stream";
}
header("Content-Type: $Mime", true );
$RegulatedFN = strtr($FileName, array( ',' => '_' ) );
// header( "Content-Length: ".filesize($File), true );
header("Accept-Ranges : bytes");
header("ETag : \"".swatchstamp()."\"" );
header("Content-Transfer-Encoding: binary");
header( "Expires: Tue 19 Jun 2007 08:52:00 GMT" );
$H = "Content-Disposition: ";
if( ! preg_match( "/MSIE 5.5/", $_SERVER['HTTP_USER_AGENT'] ) ) {
$H .= "attachment; ";
}
if( preg_match( "/MSIE/", $_SERVER['HTTP_USER_AGENT'] ) ) {
header("Pragma: public"); //HTTP/1.0
header("Cache-Control: max-age=0"); //HTTP/1.1
} else {
header("Pragma: no-cache"); //HTTP/1.0
header("Cache-Control: no-store, no-cache, must-revalidate"); //HTTP/1.1
}
header( $H . "filename=\"$RegulatedFN\"", true );
readfile( $File );
// output produced -> no more output to send
}