我正在尝试获取图像路径并在 tmp 目录中打开相应的图像,但该页面仅显示一个空的 img 占位符图片。提前致谢
public function getImage($path)
{
if($result = $this->db->prepare("SELECT filename FROM trips WHERE filename=?"))
{
$result->bind_param('s', $path);
$result->execute();
$result->bind_result($filename);
if($result->fetch())
{
header("Content-type: image/jpeg");
if(!file_exists("C:/xampp/htdocs/webshop/public/img/content/" . $filename))
{
imagefilter($image, IMG_FILTER_GRAYSCALE);
imagejpeg($image, "C:/xampp/htdocs/webshop/public/img/content/" . $filename);
}
else
{
$image = imagecreatefromjpeg("C:/xampp/htdocs/webshop/public/img/content/" . $filename);
}
imagejpeg($image);
}
else
{
echo "error";
}
}
else
{
echo "Table retrieve failed: (" . $this->db->error . ") " .$this->db->error;
}
var_dump($img);
return $image;
}