Quote:
Originally Posted by erp23
I'm having a problem reading a pdf from a longblob mysql field.
My code works in safari and firefox, but IE6 gives an error of (file could not be written to cache) and IE7 just gives a blank page. This is my code:
[PHP]<?php
if (isset($_GET['fileID']) == false) { header("Location: studentsindex.php"); exit;}
if ($_GET['referrer'] == "papers") { $table = "tbl_pastpapers"; } else {$table = "tbl_subjectmaterial"; }
mysql_select_db($database_conn_LSM, $conn_LSM);
$result=mysql_query("SELECT fileID, filepdf FROM ".$table." WHERE fileID='".$_GET['fileID']."'");
$row=mysql_fetch_assoc($result);
Header( "Content-type: application/pdf");
echo $row['filepdf'];
?>[/PHP]
Any suggestions as to how to adapt this to IE?
As PHP is executed server-side, the PHP code itself is not the problem, the output you are sending to the browser is. My guess would be that there is a problem with the headers.
The 'application/pdf' header is recognized by IE as a Acrobat Reader document, but it may require that you send the length of the document.
Try sending the 'Content-length' header and see if that helps.
-
header("Content-length: ". strlen($row['filepdf']) )";
-
You may also want to send the PDF document name to the browser, which would be done like this:
-
header("Content-Disposition: inline; filename=docname.pdf");
-