I am using this function(found at php.net) to stream a pdf from my server. It work perfect on my developing machine(apache on windows xp) but when I move it to the server I an getting corrupted pdf. I dont know where to look since there are no php errors.
The function is
Code: Select all
session_cache_limiter('none'); //*Use before session_start()
set_time_limit(0);
function DownloadFile($file,$filename) { // $file = include path
if(file_exists($file)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename=' . $filename);
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
ob_clean();
flush();
readfile($file);
exit;
}
}
Thank you