In a cloud-like web application I want to display files directly in browser, which works perfectly for .PDF and images using this code:
if (file_exists($serverfile)) {
header('Content-Type: ' . mime_content_type ($serverfile) . '; charset=utf-8');
header('Content-Disposition: inline; filename="' . $origname . '"');
header('content-Transfer-Encoding: binary');
header('Content-length: ' . filesize($serverfile));
header('Accept-Ranges: bytes');
readfile($serverfile);
//... more unrelated code
exit;
}
but I have scrumbled characters e.g. with German Umlauts, in case the file is a .CSV
I also set ini_set('default_charset', 'utf-8');
on top of the script.
What am I missing ?