DOMPDF does not render server image

-3

I'm using the dompdf library to print reports, but I do not want to render the image and it just shows me an X, here the code:

echo"<img src='$imageURL = /roda/img/.$row[ruta_imagen]'/>";
    
asked by Leonardo Rodríguez 02.06.2018 в 00:27
source

1 answer

1

You are putting the code wrong, what you have now:

echo"<img src='$imageURL = /roda/img/.$row[ruta_imagen]'/>";

You have several problems:

  • As you are writing, the src generated will be as follows:

    "VALOR_DE_IMAGEURL = /roda/img/.VALOR_DE_ROW_RUTA_IMAGEN"
    

    For example, if the initial value of $imageURL was "" and that of $row["ruta_imagen"] was "flor.jpg", then the generated code will be:

    " = /roda/img/.flor.jpg"
    

    that is not a valid route so you'll see the X or the default image for images that did not load well.

  • $row[ruta_imagen] will give a warning because ruta_imagen is nothing unless you have defined it before. It should be in quotes $row["ruta_imagen"] ... but it will work because PHP does not find the constant / variable ruta_imagen and then interprets it as the string "image_path".

  • You are concatenating the values wrongly, although this can be solved in a better way by moving the allocation of $imageURL to before echo :

    $imageURL = "/roda/img/" . $row["ruta_imagen"];
    echo "<img src='$imageURL'/>";
    
  • With that last code, it should work for you (if the image exists and is in the specified path).

        
    answered by 05.06.2018 / 16:01
    source