如何使用PHP在图像标记中设置图像路径


How to set image path in image tag using PHP

我需要一個幫助。我需要在使用 PHP 从图像标签内的数据库获取后设置图像路径。我在下面解释我的代码。

$getcustomerobj = $dbobj->getNewsData($id);
div class="input-group bmargindiv1 col-md-12">
<span class="input-group-addon ndrftextwidth text-left">Upload Image :</span>
<input type="file" class="filestyle form-control" data-size="lg" name="newsimage" id="newsimage" onChange="javascript:addImage(event,'img','disImage');">
</div>
<div id="disImage" style="display:none;"> 
<div class="input-group bmargindiv1 text-right col-md-12" >
<img src="uploads/"'.<?php echo $getcustomerobj->image ?>.' name="pro" id="img" border="0" style="width:50px; height:50px; border:#808080 1px solid;" />
 </div>

在这里,我使用$getcustomerobj从数据库获取数据,但无法显示它。请帮助我。

你做错了。路径应位于 " s 内。尝试使用 -

<img src="uploads/<?php echo $getcustomerobj->image ?>" name="pro"...

会工作。

您的代码<img src="uploads/"'.<?php echo $getcustomerobj->image ?>.' name="pro" id="img" border="0" style="width:50px; height:50px; border:#808080 1px solid;" />更改为

<img src="<?php echo 'uploads/'.$getcustomerobj->image ?>" name="pro" id="img" border="0" style="width:50px; height:50px; border:#808080 1px solid;" />