I have an image $file ( eg ../image.jpg )
which has a mime type $type
How can I output it to the browser?
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.