I'm storing pdf files as blobs in a database, but when I try to display them, I end up with the binary data being displayed rather than the actual file. I figured I should do it in pretty much the same way as with images, but it doesn't work at all. Can I use the IMG tag to display the file, or do I need to do it in a different way? I've tried using the anchor tag as well, but no luck... Has anybody got any suggestions?
/Nina
snippet from the displaying page:
<?php
dbconnection();
$query = "SELECT * FROM pdf WHERE id_no='2'";
$result=mysql_query($query);
$row=mysql_fetch_array($result);
echo $row['id_no'];
?>
<A HREF="getpdf.php?id_no=<?php echo $row['id_no']; ?>">pdf</A>
<BR>
<IMG SRC="getpdf.php?id_no=<?php echo $row['id_no']; ?>">
getpdf.php:
<?php
include "functions.php";
if($id_no)
{
dbconnection();
$query = "select pdf from pdf where id_no='$id_no'";
$result = MYSQL_QUERY($query);
$data = MYSQL_RESULT($result,0, "pdf");
header("Content-type: application/pdf");
header("Content-Disposition: attachment; filename=$id_no.pdf");
echo $data;
}
?>