streaming pdf getting corrupted
Posted: Sat Sep 13, 2008 10:50 pm
Hello,
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
So what can cause a corruped pdf? BTW, the file is NOT corrupted on the server. I ftp the file to my machine and the file is fine. Also remember that it does work on my windows machine.
Thank you
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