Show image stored in MySQL with PHP


I have a file that allows me to make modifications to a MySQL registry which includes adding an image. When I try to send the data to another file to make a PDF I do not recognize the image, it recognizes the path "images / imag1.png".


This is a fragment of the Modification.php code that allows me to store the image in the database.

    if($_FILES["archivo"]["error"] > 0){ //Archivo Modificacion.php
} else {
    $nom_archivo = $_FILES['archivo']['name'];
    $ruta = "../imagenes/". $nom_archivo;
    $archivo = $_FILES['archivo']['tmp_name'];
    $subir = move_uploaded_file($archivo, $ruta);
    include 'con.php';
    echo $sentencia_img="UPDATE ExampleTable SET imagen='$ruta' WHERE id='".$_POST['nID']."' ";
    $con->query($sentencia_img) or die ("ERROR al subir imagen".mysqli_error($con));    

The table in the DB has the column name "image" of type VARCHAR and other columns. Currently I make a query and show the result of what is in that record as

$cons = "SELECT * FROM ExampleTable where id = $nID"; //Archivo MiPDF.php

                $sqli=mysqli_query($con, $cons);
                            <td height="100"><strong>Fragment: </strong><br>'.$answ['fragmnt'].'</td>
                            <td>Xtra:<img src='.$answ['imagen'].' width="50" ></td>
            $dompdf=new DOMPDF();
            $dompdf->set_paper("A4", "portrait");

In '. $ answ [' image '].' It gives me the path where the image is saved, and what I need is for me to show the image.

asked by Vicky_96HV 27.11.2018 в 07:02

0 answers