Failed to display Longblob content on site

Asked

Viewed 22 times

1

Guys I’m making a site for a tcc of high school and good did in php a while that would pull data from a table including photo(stored as longblob), and good at the time of running this code on the page the image instead of appearing, it appears encoded, I am trying to solve this urgently but I did not find anything like I should do to show a longblob as image (phpmyadmin bank). If I remove the image and put a square for example, it pulls the other data normally.

<?php
      $tipo =$_GET["tipo"];
      $conexao = mysqli_connect("127.0.0.1","root","","db_tcc") or die ("Não foi possível se conectar com o servidor.");





        switch($tipo){
            case "0":
                    $varsql = "SELECT * FROM tb_locaissp ORDER BY id ASC";
                    break;

            case "1": case "2": case "3":
                    $varsql = "SELECT * FROM tb_locaissp WHERE TIPO='$tipo' ORDER BY id ASC";
                    break;
    }


          $carregar_guias = mysqli_query($conexao, $varsql);

      while ($linha = mysqli_fetch_array($carregar_guias))
      {
        $id = $linha["ID"];
        $img = $linha["FOTO"];
        $nome = $linha["NOME"];
        $desc = $linha["DESCRICAO"];




        echo "<div class='loc'>
        <table class='tablel'>
        <tr><td class='nome'>$nome</td>  <td><img class='contador' src='like' '> </td></tr>
        <tr><td class='imglo'><img src='$img'></td></tr>
        <tr><td class='desc'>$desc</td></tr>
        </table></div>";
        echo "<br><br>";

      }
    ?>
  • mine does not appear in binary but in several different characters. if I try the solution to the top where would put the variable of php?

  • It seems to me the same solution, you’ve tested?

  • I tested along with the GD code I found here https://stackoverflow.com/questions/6106470/php-convert-a-blob-into-an-image-file and strangely the image appears but underneath it is the same characters occupying a lot but a lot of space.

  • ob_start(); imagejpeg($img, null, 80); $data = ob_get_contents(); ob_end_clean(); echo '<img src="data:image/jpg;Base64,' . base64_encode($date) . '" />';

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.