我正在尝试显示 MySQL 数据库中的图像,如果图像是 JPG,我的代码可以正常工作,但是如果我修改内容类型以显示 PNG,它就不起作用......我该如何制作为PNG工作??
<?php
// configuration
require("../includes/config.php");
header('Content-type: image/JPG');
$username = "xxxxx";
$password = "*****";
$host = "localhost";
$database = "database";
@mysql_connect($host, $username, $password) or die("Can not connect to database: ".mysql_error());
@mysql_select_db($database) or die("Can not select the database: ".mysql_error());
$query = mysql_query("SELECT * FROM images");
while($row = mysql_fetch_array($query))
{
echo $row['image'];
}
?>
此外,是否可以显示图像及其名称和描述?谢谢!