Then you need to change the code. This is viewing code that we use. It depends on the browser sice IE does it different then other browsers.
Be aware chrome/chromium do not work this way, they always download.
//if not applewebkit so if ie/opera/.. and alike
if (isset($_SERVER['HTTP_USER_AGENT']) && (false == strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'applewebkit'))){
header("Content-Description: File Transfer");
header("Expires: 0");
header("Pragma: public");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private");
}
$finfo=finfo_open(FILEINFO_MIME_TYPE);
if (false!==strpos($_SERVER['HTTP_USER_AGENT'], ' MSIE 8.0;'))
{
//header('Content-Type: application/force-download');
header("Content-Type: application/octet-stream");
}else{
if (strtolower(substr($filename,-4))=='.eml'){
header("Content-Type: message/rfc822");
}else{
header("Content-Type: ".finfo_file($finfo,$trab_doc));
}
}
finfo_close($finfo);
// header("Content-Disposition: attachment; filename=\"" . urlencode($nm_nome_doc) . "\" filename*=UTF-8''" . urlencode($nm_nome_doc));
$sProtectedFilename = str_replace(array(' ', "'", '!', ',', '-', '+'), array('__SC_SPACE__', '__SC_QUOTES__', '__SC_EXCLAMATION__', '__SC_COMMA__', '__SC_MINUS__', '__SC_PLUS__'), $nm_nome_doc);
$sProtectedFilename = rawurlencode(basename($sProtectedFilename));
$sProtectedFilename = str_replace(array('__SC_SPACE__', '__SC_QUOTES__', '__SC_EXCLAMATION__', '__SC_COMMA__', '__SC_MINUS__', '__SC_PLUS__'), array(' ', "'", '!', ',', '-', '+'), $sProtectedFilename);
//if chrome
if (isset($_SERVER['HTTP_USER_AGENT']) && false !== strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'chrome'))
{
header("Content-Disposition: attachment; filename=\"" . $sProtectedFilename . "\"");
}
//if any other
elseif (isset($_SERVER['HTTP_USER_AGENT']) && false !== strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'applewebkit'))
{
header("Content-Disposition: attachment; filename=\"" . $nm_nome_doc . "\"");
}
elseif (isset($_SERVER['HTTP_USER_AGENT']) && false !== strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'firefox'))
{
header("Content-Disposition: attachment; filename=\"" . $nm_nome_doc);
}
elseif (isset($_SERVER['HTTP_USER_AGENT']) && false!==strpos($_SERVER['HTTP_USER_AGENT'], ' MSIE 8.0;'))
{
//header('Content-Type: application/force-download');
header("Content-Disposition: attachment; filename=\"" . sProtectedFilename."\"");
}
elseif (function_exists('NM_utf8_urldecode') && $nm_nome_doc != NM_utf8_urldecode($nm_nome_doc)){
header("Content-Disposition: attachment; filename=\"" . $nm_nome_doc . "\" filename*=UTF-8''" . $sProtectedFilename);
}else{
header("Content-Disposition: attachment; filename=\"" . $sProtectedFilename . "\"");
}
header("Content-Length: ".(string)filesize($trab_doc));
header('Content-Transfer-Encoding: binary');
readfile($trab_doc);
}
Browsers use different tactics to show a file. And besides that, the client must be able to derive the filetype so for windows for example the file viewer should be installed properly.