开发者

PHP / MySQL: How to include a normal blob image in a php-page?

I've now a blob file with an image in it. How can i insert it into开发者_StackOverflow中文版 a page? Around is some other text & stuff, so I can't set the header to

header("Content-type: image/gif"); 

or something...

thx for help

flo


you would need to serve the image separately and set the header. IE, create another page 'images.php' that will return the image, and then in the page where you want the image just put the images.php?id=uniqueid and the source


You'll have to output the image in a separate script where you can do the header() call. There are data: URIs that allow embedding images in HTML pages directly but they suck for a multitude of reasons.


You can either try to embed the image using a data-URI (not supported across all browsers and most probably not practical in terms of page size and client side caching) or create a second script that only sends the blob (using the correct content-type) as an image to the user and embed this blob using a normal <img> tag.


You cannot do this directly. You'll have to make a new PHP script that extracts the blob data from the database, and set the appropriate headers.

However, there is another (browser dependant) way:

Enclose the base64 encoded blob in an tag. More info on this can be found here: http://bit.ly/ex0BSN

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜