Do it like this:
if ($showfile == true) // Send Mime-Type and output PDF document raw.
{
$file_name_arr = report_make_filename ($filename_module, $time_stamp); // Generate a nice name for the file
$size = strlen ($data);
if ($size > 0) // Check whether we have anythting to send
{
Header ("Content-type: application/pdf"); // Header ("Content-type: application/".$file_name_arr[1]."");
Header ("Content-Disposition: inline; filename=".$file_name_arr[0]."");
Header ("Content-length: " .$size);
header ("Expires: 0");
header ("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header ("Pragma: public");
echo $data;
}
}
if ($downloadfile == true) // Send a force download and output PDF document raw.
{
$file_name_arr = report_make_filename ($filename_module, $time_stamp); // Generate a nice name for the file
$size = strlen ($data);
if ($size > 0) // Check whether we have anythting to send
{
header ("Content-Type: application/force-download");
header ("Content-Length: ".$size."");
header ("Content-Disposition: attachment; filename=".$file_name_arr[0]."");
header ("Content-Transfer-Encoding: binary");
echo $data;
}
}
This is from an oracle app, but you can easily derive it for your needs.
cu