Error including image with <img .../> tag by string in PHP

Asked

Viewed 86 times

0

I cannot make a referenced image in the code below appear. What may be the problem?

<style>

    table{width:  100%;$borda;$fonte;}
    th{text-align: center;}
    td{text-align: center;$tam_etiq}
    tr{ }
    td.col1{text-align: center;}
    td.titulo{font-size: 24px;$tit_neg;$cor_tit;$sizetit;$tit_center;}
    td.desc{color:#$cor_desc;$desc_neg;$sizedesc}

</style>
";

$titulo = $_POST['titulo'];
$descr1 = $_POST['descricao1'];
$descr2 = $_POST['descricao2'];
$descr3 = $_POST['descricao3'];
$quant_linhas = count($titulo);
$imagem = $_FILES["<img src=https://servicosespeciais.com.br/comfica/email/logotipo.png />"];


//echo $quant_linhas;

$html.= "<table>";
$html.="<col style='width: 100%' class='col1'>";
$html.="<col style='width: 100%'>";
$html.="<col style='width: 100%'>";
for ($i = 0; $i < $quant_linhas; $i++) {
    $j++;
    $k++;
    if ($j == 1) {
        $html.= "<tr>";
    }
    $html.="<td>";
    $html.="<table frame='box'>";
    $html.="<col style='width: 100%' class='col1'>";
    $html.="<col style='width: 100%'>";
    $html.="<col style='width: 100%'>";
    $html.="<col style='width: 100%'>";

    $html.="<tr>";
    $html.="";
    $html.="</tr>";
    $html.="<tr>";
    $html.="<td class='titulo'>$imagem</td>";
    $html.="</tr>";

    $html.="<tr>";    
    $html.="<td class='titulo'> ROMANEIO DE TRANSPORTE </td>";
    $html.="</tr>";
    $html.="<tr>";
  • 1

    Boy explain better, not only post the code no, bad to help understand your problem

  • Always enter the complete code. Incomplete code makes us think that your error may be higher or lower. Or even prevent us from helping appropriately. And always explain the problem situation thoroughly and concisely.

1 answer

2

Problem

Look at this line:

$imagem = $_FILES["<img src=https://servicosespeciais.com.br/comfica/email/logotipo.png />"];

That’s basically impossible. You don’t have this whole string as a $_FILES index for the simple fact that it is an image HTML tag (<img .../>).

Now look at this line:

$html.="<td class='titulo'>$imagem</td>";

You clearly just wanted the image tag here. Not the value of $_FILES['...'] where the index is an image HTML tag.

Fixing the problem

Change the line below:

$imagem = $_FILES["<img src=https://servicosespeciais.com.br/comfica/email/logotipo.png />"];

For:

$imagem = "<img src=https://servicosespeciais.com.br/comfica/email/logotipo.png />";

If the image in the specified address exists, it will appear with this modification.

Extra reading suggestion

If you do, in the future, upload of images, take a look in this article' of PHP.net.

Browser other questions tagged

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