开发者

PHP fetch images stored on database

开发者 https://www.devze.com 2023-04-01 15:31 出处:网络
I manually inserted a image in longblob field named image ...the image is .gif so i entered mimetype as \'im开发者_运维问答age/gif\' but it isn\'t working??

I manually inserted a image in longblob field named image ...the image is .gif so i entered mimetype as 'im开发者_运维问答age/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 ???


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

0

精彩评论

暂无评论...
验证码 换一张
取 消