Hi,
I have a MySQL database, where PDF dokuments are stored in BLOB fields.
Trough a web interface, users can click on a link and open the PDF document in a new browser window (if acrobat reader is installed of course).
The link to a PDF might look like:
pdf.php?ID=38&name=fil.pdf
But IE seems to overlook the mime type of the file, and looks on the filename instead..
Even if I specify a filename in the headers, it seems to look at the filname and ignores the mime type.
The result is that IE pop's up a dialog box asking "Save file, or open in new windows".
I want IE to open the PDF file in the current window, like Netscape does..
Here's the code for the script who fetches the PDF file from the database and output's it to the browser:
<?
include("inc-db.php");
$query = "select PDF,FILNAVN from ANNONSE where ID = $ID";
$resultat = mysql_db_query($DB,$query,$sql);
if ( ! $resultat ) {
db_error($sql);
exit;
}
$BILDE = mysql_result($resultat, 0, "PDF");
$FILNAVN = stripslashes(mysql_result($resultat, 0, "FILNAVN"));
if(strstr($HTTP_USER_AGENT,"MSIE 5."))
{
header("Content-Disposition: filename=".$FILNAVN);
}
else
{
header("Content-Disposition: attachment; filename=".$FILNAVN);
}
header("Content-Transfer-Encoding: binary");
header("Content-type: application/pdf");
echo $BILDE;
?>