从mysql php检索图像时不显示结果

时间:2018-06-25 19:34:26

标签: php

在进行查询以及在浏览器中进行查询时,它没有显示图像

图像斑点

这是我的代码

<?php 
$con = new mysqli ('localhost', 'cualquiera', '123123','rier');
$datos = $con->query("SELECT * FROM fotos  ") ;?>
<?php  while ($user = $datos->fetch_assoc()){ ?>
<tr>  
<td class="xl80"><div align="center" class="style84"><a 
href="./autos/304862/304862.htm"><strong><?php echo $user['modelo'] ;?>
<?php echo $user['ubicacion'] ; ?></strong></a></div></td>
<td class="xl80"><div align="center" class="style84"><a 
href="./autos/304862/304862.htm"><strong><?php echo $user['anio'] ; ?> 
</strong></a></div></td>
<td class="xl80"><div align="center" class="style84"><a 
href="./autos/304862/304862.htm"><strong><?php echo $user['chasis'] ; ?> 
</strong></a></div></td>

<td class="xl80"><div align="center" class="style84"><a 
href="./autos/304862/304862.htm"><strong><?php echo $user['transmision'] 
; ?></strong></a></div></td>
<td class="xl80"><div align="center" class="style84"><a 
href="./autos/304862/304862.htm"><strong><?php echo $user['color'] ; ?> 
</strong></a></div></td>  
<td class="xl80"><div align="center" class="style84"><a 
href="./autos/304862/304862.htm"><strong><?php echo $user['estado'] ; ?> 
</strong></a></div></td>
<td class="xl80"><div align="center" class="style84"> <?  echo '<img 
src="data:image/jpeg;base64,'.base64_encode( $user['imagen'] ).'"/>'?>                                      
</div></td>
</tr>
<?} ?>

in this image you can see the result

enter image description here

1 个答案:

答案 0 :(得分:1)

您需要确保该值是整个图像的有效Base64值,请查看此答案How to display Base64 images in HTML?