The following PHP snippet is causing an internal 500 error and I believe it's one or more of the headers. I have enabled error reporting but is it reporting nothing. Can someone see what the problem may be? Thanks.
$file = CLIENTFOLDERS.$_GET['download'];
$fileSize = filesize($file);
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$type = finfo_file($finfo, $file);
finfo_close($finfo);
header("Cache-Control: private");
header("Content-Type: ".$type);
header("Content-Length: ".$fileSize);
header("Content-Disposition: attachment; filename=".basename($file));
readfile($file);
exit();
Oddly enough, the file is downloaded and I get response headers back:
Cache-Control:private
Connection:Keep-Alive
Content-Disposition:attachment; filename=CPS Letterhead form.doc
Content-Length:4
Content-Type:application/msword
Date:Mon, 10 Feb 2014 20:21:00 GMT
Expires:Thu, 19 Nov 1981 08:52:00 GMT
Keep-Alive:timeout=5, max=100
Pragma:no-cache
Server:Apache/2.4.7 (Win32) PHP/5.5.6
X-Powered-By:PHP/5.5.6
But the MS Word and Excel documents are corrupted. PDF and text files load fine. Have not checked image files.