如何将此图像保存为变量?

时间:2018-03-09 22:12:27

标签: php

我需要知道如何将这行代码保存为变量(如果可能的话),这样我就可以将它放在一个包装器中以显示博客文章。如果不可能,还有其他办法吗?提前谢谢。

<img src="imageView2.php?id=<?php echo $row["id"]; ?>"/>

这是包装器:

$newtext3 = wordwrap($poets, 65, "\n", true);

这是$ poets变量(博客文章)

$poets .= "<a class='demo shareSelector' <a class='eh3' style='' 
href='javascript:;' ><h2 class='eh4' href=''> Category:$category</h2><h1 
style='color:cyan; text-align:center; '>$title</h1><h3 >$date</h3><h2 
class='eh4'>$output</h2></a></a>
<hr>";

这是imageView2.php页面:

<?php
$conn = mysqli_connect("localhost", "root", "");
mysqli_select_db ($conn,'blog');
if(isset($_GET['id'])) {

$sql = "SELECT imageType,imageData FROM posts WHERE id=" . $_GET['id'];

$result = mysqli_query($conn,$sql) or die("<b>Error:</b> Problem on 
Retrieving Image BLOB<br/>" . mysqli_error($conn));
$row = mysqli_fetch_array($result);
header("Content-type: " . $row["imageType"]);
echo $row["imageData"];


}
mysqli_close($conn);
?>

0 个答案:

没有答案