简体   繁体   中英

PHP - Not able display images which src comes from database

<i><img src="<?php echo $path ;?>" alt="<?php echo $path;?>" style="width:250px;height:250px;"></i>

这里$path是到单独驱动器上该映像的绝对路径(E:/)

As you are running your script from the server, cause a PHP script. Lets say you have your script in the directory named myFirstScript , inside this folder you have a file named script.php where you wrote your this code.

<i><img src="<?php echo $path ;?>" alt="<?php echo $path;?>" style="width:250px;height:250px;"></i>

So the question is what is the $path here? OK, don't worry, because you are using this $path to the src of an image so it is a image file. And this image file must in the same directory named myFirstScript . Say you have the image named image.jpg . so your path is: $path = 'image.jpg';

Example:

<?php $path = 'image.jpg';?>
<i><img src="<?php echo $path ;?>" alt="<?php echo $path;?>" style="width:250px;height:250px;"></i>

Real time Example:

<?php $path = 'http://placehold.it/350x150';?>
<i><img src="<?php echo $path ;?>" alt="<?php echo $path;?>" style="width:250px;height:250px;"></i>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM