Show BLOB

I need to show a PDF file that i have in a mysql BLOB field.
How can i do this?

I have a php code that works in a php, but if i put in the blank form doesn?t work

<?php
########## imagen_mostrar.php ##########

deve recibir el id de la imagen a mostrar

http://www.lawebdelprogramador.com

Conectamos con la base de datos

$link=mysql_connect(“localhost”,“my”,“my”);
mysql_select_db(“Docs”,$link);

Buscamos la imagen a mostrar

$result=mysql_query(“SELECT Doc FROM Docs WHERE Cod=”.$_GET[“id”],$link);
$row=mysql_fetch_array($result);

Mostramos la imagen

header(‘Content-type: application/pdf’);

header(‘Content-Disposition: attachment; filename=“downloaded.pdf”’);

echo $row[“Doc”];
?>

Re: Show BLOB

You may have to modify your headers. Here is some code I used for XLS download in an app:


// Sending headers to force the user to download the file
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: inline;attachment;filename="'.$reports_array['report_name'].'.xls"');

Regards,
Scott.

Re: Show BLOB

Greate thanks scott

Re: Show BLOB

Thanks a lot, Scott

I will try it

Re: Show BLOB

I’ll try and doesn’t work

Server internal error 500

This is my code:

########## imagen_mostrar.php ##########

deve recibir el id de la imagen a mostrar

http://www.lawebdelprogramador.com

Conectamos con la base de datos

$link=mysql_connect(“localhost”,“M”,“M”);
mysql_select_db(“Docs”,$link);

Buscamos la imagen a mostrar

$result=mysql_query(“SELECT Doc FROM Docs WHERE
CodDoc=117338”,$link);
$row=mysql_fetch_array($result);

Mostramos la imagen

header(“Last-Modified: " . gmdate(“D, d M Y H:i:S”) . " GMT”);
header(“Cache-Control: no-store, no-cache, must-revalidate”);
header(“Cache-Control: post-check=0, pre-check=0”, False);
header(“Pragma: no-cache”);
header(‘Content-type: application/pdf’);
header(‘Content-Disposition: inline;attachment; filename=“Doc.pdf”’);
echo $row[“Doc”];
?>

Thanks

Re: Show BLOB

Error 500 means there is an generic error.

Please use Firebug / FirePHP ( or place print/echo in your code ) and find out what is not as expected. It could be as simple as a path problem to your PDF file.
Pay attention to the NET and CONSOLE tabs in firebug.

Regards,
Scott.