kshitij
kshitij

Reputation: 111

PHP fetch images stored on database

I manually inserted a image in longblob field named image ...the image is .gif so i entered mimetype as 'image/gif' but it isn't working??

  $result=mysql_query("SELECT image FROM page WHERE number=$ide");

 while($image=mysql_fetch_array($result))
 {
     header('Content-type:'.$image['mimetype']);


    echo $image['image'];

Please help it is showig some random binary text instead of the image it also says undefined index mimetype have i done something wrong in defining it ???

Upvotes: 0

Views: 871

Answers (1)

Treffynnon
Treffynnon

Reputation: 21553

You need to get the mime type in your SQL query like so:

$result=mysql_query("SELECT image, mimetype FROM page WHERE number=$ide");

The mimetype should be image/gif

Upvotes: 3

Related Questions