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 '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
精彩评论