>I have a blob in the database. I want to open a file=BLOB in the browser such
>a way as if I clicked on a link. So if it is pdf, its opened by pdf plugin,
>if it is doc, it is open by word plugin, if it is zip the dialog for
>opening/saving to disk is opened, if it is jpeg it is directly displayed in
>the browser. The header() function with Attachment doesn't work. Any idea how
>to achieve this effect without writing the BLOB to a temporary file somewhere
>on the disk and opening this file ???


You need to get header() to work. Use header() to deliver the correct
content-type for the file, then echo the $BLOB data. That's it. Show your
code if it's not working.


resulting document shows an icon for non-existent image called
script-name.php with byte size of -1 and dimensions 28x30 pixels (as
seen in properties).

and this is my code :


.... connection to SQL


$query = sprintf("SELECT * FROM external_service ORDER BY `timestamp` DESC");
$result = mysql_query($query, $connection);
if(($result) AND (mysql_num_rows($result) != 0)):
$zaznam = mysql_fetch_array($result);
$date = $zaznam[0];
$pic = $zaznam[4];
$type = $zaznam[1];
$size = $zaznam[2];
$name = $zaznam[3];


header("Content-Type: $type");
header("Content-length: $size");
header("Content-Disposition: attachement; filename=$name");
header("Content-Description: PHP Generated Data");
echo $pic;

.....






-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to