I have an image $file
( eg ../image.jpg
)
which has a mime type $type
How can I output it to the browser?
For the next guy or gal hitting this problem, here's what worked for me:
ob_start();
header('Content-Type: '.$mimetype);
ob_end_clean();
$fp = fopen($fullyQualifiedFilepath, 'rb');
fpassthru($fp);
exit;
You need all of that, and only that. If your mimetype varies, have a look at PHP's mime_content_type($filepath)