Yo en la base de datos tengo dentro de la tabla un campo IMAGE y las imagenes que tengo dentro de la misma son PNG y estan grabadas en formato binario.
Para ver las mismas utilizo el siguiente codigo.
Código PHP:
<?php
$id = "$NUM_FIR";
$StringQuery = "select * from tabla where cql_recno=$id";
$ConnectServerID = odbc_connect( $ServerName, sa, sa);
if( $ConnectServerID ) {
$ResultQueryID = odbc_do( $ConnectServerID, $StringQuery);
if( $ResultQueryID > 0 ) {
$datrec = odbc_result( $ResultQueryID, "dat_rec");
// header("Content-type: image/png");
echo $datrec;
}
if ($datrec == 0)
{
header ("Content-type: image/png");
// se crea la imagen
$imagen2 = imagecreate(250, 100);
// se crea el color de fondo
$color = imagecolorallocate($imagen2, 255, 255, 255);
// se muestra la imagen y se liberan los recursos
imagepng($imagen2);
imagedestroy($imagen2);
}
odbc_free_result( $ResultQueryID );
odbc_close( $ConnectServerID );
}
?>