for example, if it's an image file, they can use my "generic" page as the source of the image like so:
<img src="http://www.mydomain.com/files?fid=343"> <-- where fid is the id of the file on the database. It grabs the location of the file from the db, and then uses my headers to decide what to do with it. Here is my problem/question. If it's a pdf, I want it to just open in the browser if they visit the link like this: http://www.mydomain.com/files?fid=345. Right now it's asking if they want to save or open the file, if they select open, it doesn't know which program to open it with, but if they select save, it saves the file just find and they can open it from their machine locally. I want it to open pdfs within the browser itself.
here is the header information that I'm using:
Code: Select all
$size = filesize($gtfile['fileloc']);
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Type: ".$content);
$inora = ($in ? "inline" : "attachment");
$header="Content-Disposition: ".$inora."; filename=".$gtfile['fileloc'].";";
header($header );
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".$size);
echo readfile($gtfile['fileloc']);
exit;any ideas?