简体   繁体   中英

How can i get an image from mysql database through php

I can insert my image in database but i dont find a way to get it.The image was inserted through the website. My php code:

require_once('something.php');

    $codservico=$_GET['id'];

    $consulta="select * from xxxxx where xxxxx=".$something;
    $resultado=mysql_query($consulta);
    $nregistos=mysql_num_rows($resultado);
if($nregistos>0)
{
    for ($i=0; $i<$nregistos; $i++){
        $registo=mysql_fetch_array($resultado);
        echo '<tr class="show">';
        echo '<td class="show"><img src="data:image;base64,'.$registo['image'].'"></td>';
        echo '</tr>';
    }
}
else
{
    echo "<td colspan='8' align='middle'>Nenhum registo encontrado</td>";
}

And i get something like this: http://costumerbook.netai.net/Capturar.PNG

您需要指定Content-Type (图像格式) data:image/png;base64data:image/png;base64

echo '<td class="show"><img src="data:image/png;base64,'.$registo['image'].'"></td>';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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