You can use finfo
(PHP 5.3+) to get the right MIME type.
$filePath = 'YOUR_FILE.XYZ';
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$contentType = finfo_file($finfo, $filePath);
finfo_close($finfo);
header('Content-Type: ' . $contentType);
readfile($filePath);
PS: You don't have to specify Content-Length
, Apache will do it for you.