这是我的代码 而不是图片,而是显示随机数
<?php
while($res = mysqli_fetch_assoc($show)){
echo "<div class='post' style='background-image: url(\"data:base64;base64.$res[image]\").'>";
这是我的代码 而不是图片,而是显示随机数
<?php
while($res = mysqli_fetch_assoc($show)){
echo "<div class='post' style='background-image: url(\"data:base64;base64.$res[image]\").'>";
首先,您必须使用PHP的base64_encode
函数在base64中对图像源进行编码。
$base64image = base64_encode($res['image']);
echo "<div class='post' style='background: url(data:image/jpeg;base64,$base64image);'>";
请注意,url
参数指定了image/jpeg
,但您必须相应地将其更改为图像类型。