如何显示从数据库中检索到的图像?
问题描述:
我知道如何检索图像以外的数据
i know how to retrieve data other than image
$q="select name from brands";
$q_rs = $this->db->query($q);
$result = $q_rs->result();
foreach($result as $i)
{
foreach($i as $j)
echo $j."<br>";
}
但是,如果我尝试通过这种方法显示检索到的图像,则屏幕上会显示很多原始数据而不是图像.我在Google上搜索了一下,并了解到应该编写一个标头,以告诉浏览器该数据是图像.以下是我编辑的代码,但未显示静止图像,出现带有十字的框
but if i try to display the retrieved image by this method, lot of raw data display on the screen not image. i google it and learn that a header should be written that tell the browser that the data is an image. below is my edited code but still image is not displaying, a box with a cross is appearing
$q="select image from brands";
$q_rs = $this->db->query($q);
$result = $q_rs->result();
header("Content-type: image/jpeg");
foreach($result as $i)
{
foreach($i as $j)
echo $j."<br>";
}
答
q = " ;
q="select name from brands";
q_rs =
q_rs =
this-> db-> query(
this->db->query(