Reputation: 419
I need to insert php code within a text. It is an image but uses an absolute path through php. I would like to execute but the image is not displayed within the text.
<img class="image-left" src="<?php $_SERVER['DOCUMENT_ROOT']?>/abuelo/abuelo.png"/>Since the founding of Grandpa in 2003 we have offered a different type of shopping. We have always had service...
I always use in my projects Because I find very useful, if you change the place .php file or meta in a folder always find the images.
I would be very utilizad it can also be included in the database, in case I need to show information with your image added elsewhere on the page regardless of where the file is hosted.
Is there any way to insert the image in the database and make it work?
Upvotes: 1
Views: 67
Reputation: 16963
All you need is an echo
<img class="image-left" src="<?php echo $_SERVER['DOCUMENT_ROOT']; ?>/abuelo/abuelo.png"/>Since the founding of Grandpa in 2003 we have offered a different type of shopping. We have always had service...
Edited:
The problem is, you are referencing your image as,
C:/wamp/www/
which will never work. You should be referencing it as localhost
. Like this:
<img src="<?php echo "http://" . $_SERVER['SERVER_NAME']; ?>/abuelo/abuelo.png" />
Upvotes: 3