Ver Mensaje Individual
  #1 (permalink)  
Antiguo 24/12/2009, 05:31
albertrc
 
Fecha de Ingreso: febrero-2009
Mensajes: 443
Antigüedad: 15 años, 2 meses
Puntos: 1
ayuda para mostar imagen jpeg me devuelve la url y no la imagen

me devuelve este resultado i no la foto
http://localhost/php/cacau30/foto.php?id_foto=0000


CREATE TABLE IF NOT EXISTS foto (
id_foto SMALLINT(4) UNSIGNED ZEROFILL NOT NULL,
nombre_foto VARCHAR(50) UNIQUE NOT NULL,
foto MEDIUMBLOB NOT NULL,
categoria_foto VARCHAR(50) NOT NULL,
format_foto VARCHAR(50) NOT NULL,
foto_id_producte SMALLINT (3) UNSIGNED ZEROFILL NOT NULL,
CONSTRAINT pk_id_foto PRIMARY KEY (id_foto),
)ENGINE=InnoDB;


insert
id_foto nombre_foto foto categoria_foto formato_foto foto_id_producte
0000 foto.jpeg [BLOB - 7.2 KB] reposteria image/jpeg 000











indice.html
<li><a href="foto.php?id_foto=0000">foto</a></li>

foto.php
<?
header("Content-Type: image/jpeg");
$link = mysqli_connect($hostname,$user,$password,$database );
$query = "select foto from foto where id_foto= $_GET[id_foto] ";
$result = mysqli_query($link, $query);

/* associative array */
while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)){
echo "{$row['foto']}<br>\n";
}

/* free result set */
mysqli_free_result($result);

/* close connection */
mysqli_close($link);
?>