Simple question, probably been asked a million times but I've searched and am no closer to getting this to work.
I have a PHP script within the UserFrosting framework that serves a file to the user via their browser. I would like the file to open in their browser if they select 'Open' insteand of download.
Problem is, the only things that are opening properly are text files. Anything else (PDFs and JPGs tested so far) are just opening as a page of ASCII/garbled code instead of being interpreted as a PDF or an image.
Here's the code I'm using:
header('Content-Type: '. $mime);
header('Content-Length: ' . filesize($diskname));
header('Content-Disposition: inline; filename=' . $savename);
retu readfile($diskname);
$mime
is the Mime type of the file set via a function, so could be application/pdf
or image/jpeg
for the files I'm trying to view so far.
Does anyone have any ideas why the files aren't opening properly?