RECUPERAR IMAGENES DE CAMPOS MYSQL
Publicado por Pablo (1 intervención) el 02/10/2008 14:03:23
Buenas tardes, tengo un gran problema, estoy intentando recuperar imagenes previamente guradadas en un campo blob de mysql, para recuperarlas uso el siguiente codigo :
/******************************************************************************************************************************************
$conexion= mysql_connect(servidor,usuario,pass) or die ("NO SE HA PODIDO CONECTAR CON EL SERVIDOR, INTENTELO MAS TARDE ....");
mysql_select_db(esquema);//selecciono la base de datos con la que voy a trabajar
$consulta1="select id_foto, foto, tipo from tfotos order by id_foto";
$respuesta1=mysql_query($consulta1,$conexion);
$n_lineas=mysql_num_rows($respuesta1);
$tablamin='<TABLE BORDER =1><TR ALING = CENTER>';
for ($i=0;$i<=$n_lineas;$i++){
//construimos la tabla dinamicamente
$img_min= mysql_result($respuesta1,$i,1);
$img_tipo= mysql_result($respuesta1,$i,2);
header("Content-Type: $img_tipo");
$tablamin.= '<TD>' .$img_min. '</TD>' ;
}
$tablamin.='</TR></TABLE>';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Recuperar Imagen</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<?php
echo $tablamin;
?>
</body>
</html>
/****************************************************************************************************************************************
Creo que el problema es que no me funciona correctamente la funcion header, mi consulta es la siguiente ¿Hay que modificar algún parametro en el fichero php.ini o en el http.conf? Creo que el codigo es correcto, si no fuera así postead la corrección, muchas gracias.
/******************************************************************************************************************************************
$conexion= mysql_connect(servidor,usuario,pass) or die ("NO SE HA PODIDO CONECTAR CON EL SERVIDOR, INTENTELO MAS TARDE ....");
mysql_select_db(esquema);//selecciono la base de datos con la que voy a trabajar
$consulta1="select id_foto, foto, tipo from tfotos order by id_foto";
$respuesta1=mysql_query($consulta1,$conexion);
$n_lineas=mysql_num_rows($respuesta1);
$tablamin='<TABLE BORDER =1><TR ALING = CENTER>';
for ($i=0;$i<=$n_lineas;$i++){
//construimos la tabla dinamicamente
$img_min= mysql_result($respuesta1,$i,1);
$img_tipo= mysql_result($respuesta1,$i,2);
header("Content-Type: $img_tipo");
$tablamin.= '<TD>' .$img_min. '</TD>' ;
}
$tablamin.='</TR></TABLE>';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Recuperar Imagen</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<?php
echo $tablamin;
?>
</body>
</html>
/****************************************************************************************************************************************
Creo que el problema es que no me funciona correctamente la funcion header, mi consulta es la siguiente ¿Hay que modificar algún parametro en el fichero php.ini o en el http.conf? Creo que el codigo es correcto, si no fuera así postead la corrección, muchas gracias.
Valora esta pregunta


0