Image Link for testing
When I click the clink, Chrome, Safari and FF all automatically download a file rather the view it in the browser. How can I make it viewable in the browser? Using the link and a img
tag works fine, it's just when used directly that it forces a download.
PHP
// Figure the mime type
$mimetypes = array(
'png' => 'image/png',
'jpg' => 'image/jepg',
'gif' => 'image/gif',
'css' => 'text/css',
'js' => 'application/x-javascript'
);
$ext = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
$mime = "application/octet-stream";
if(array_key_exists($ext, $mimetypes)) {
$mime = $mimetypes[$ext];
}
header('Content-Type: ' . $mime);
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($filename));
readfile($filename);