繁体   English   中英

PHP图像检索不显示mysqli

[英]php image retrieve doesn't show mysqli

我从phpmyadmin数据库渲染存储的图像时遇到问题。

我有两个文件,第一个是image.php,它假设是从数据库中检索图像:

<?php
ini_set('display_errors',1);
error_reporting(E_ALL);
$conn = mysqli_connect("hostname","username","password");
if(!$conn)
{
echo mysql_error();
}
$db = mysqli_select_db("imagestore");
if(!$db)
{
echo mysql_error();
}
$ano = $_GET['ano'];
$q = "SELECT aphoto,aphototype FROM animaldata where ano='$ano'";
$r = mysqli_query("$q",$conn);
if($r)
{

$row = mysqli_fetch_array($r);
$type = "Content-type: ".$row['aphototype'];
header($type);

readfile($ano);
echo mysql_real_escape_string.$row['aphoto'];
}
else
{
echo mysql_error();
}

?>

和show.php,假设它显示检索到的图像:

 <?php
//show information
ini_set('display_errors',1);
error_reporting(E_ALL);

include "connect.php";


$q = "SELECT * FROM animaldata";
$r = mysqli_query($conn,$q);
if($r)
{
while($row=mysqli_fetch_array($r))
{
//header("Content-type: text/html");
echo "</br>";
echo $row['aname'];
echo "</br>";
echo $row['adetails'];
echo "</br>";

//$type = "Content-type: ".$row['aphototype'];
//header($type);
echo "<img src=image.php?ano=".$row['ano']." width=300 height=100/>";


}
}
else
{
echo mysql_error();
}
?>

当我尝试show.php时,我得到以下结果:

在此处输入图片说明

我将非常感谢您的帮助,因为我尝试了许多不同的代码,但是找不到解决方案,但仍然得到相同的结果。

谢谢。

您应该删除不需要的readfile行,以及下面一行的mysqli_real_escape_string 否则,这似乎可以正常工作,但在不知道如何存储图像的情况下我无法确定。 例如,如果您将它们存储为base64编码,则需要回显base64解码的字符串。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM