我有这段代码可以帮助我查看文章。这篇文章包含一张照片。照片已保存在数据库中,但正在检索中。它仍然是二进制文件。可能是什么问题? 这是以下代码: view_aboutme.php
<?php
include ("../connect/connection.php");
require_once("../connect/connection.php");
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Admin</title>
<!----Favicon---->
<link rel="icon" href="../img/favicon.ico" />
<body>
<?php
$sql= mysqli_query($link,"SELECT * FROM about") or die(mysqli_error($link));
while($row=mysqli_fetch_assoc($sql)){
$id=$row['About_ID'];
$title=$row['About_title'];
$imagetmp=$row['About_photo'];
$story=$row['About_post'];
echo '<tr>
<td>'.$title.'</td>
<td>'.$imagetmp.'</td>
<td>'.$story.'</td>
<td> <img src = aboutfetch_image.php?About_ID='.$id.' width=100 height=100 ></td>
<td><a href="edit_aboutme.php?id='.$id.'">Edit</a></td>
<td><a href="delete_aboutme.php?id='.$id.'">Delete</a></td>
</tr>';
}
?>
应该转换图像的文件称为 aboutfetch_image.php 。代码如下:
<?php
include ("../connect/connection.php");
require_once("../connect/connection.php");
header("content-type:image/jpeg");
$id=$_GET['About_ID'];
$sql="select About_photo from about where About_ID=".$id."";
$var=mysql_query($sql);
//echo($sql);
if($row=mysql_fetch_array($var))
{
$imagetmp=$row['About_photo'];
}
echo $imagetmp;
?>