Reputation: 3509
I'm trying to display some images on a website, but for some reasons, they are not showing up. This is the code I'm using, which is similar to what I found on the internet, but it just prints Error. How can I fix this?
<?php
echo '<img src="D:/website/images/pic.jpg" alt="Error" />';
?>
Upvotes: 0
Views: 5118
Reputation: 8823
The best way is to use relative paths:
src="/path/to/image.jpg"
Upvotes: 1
Reputation: 1639
images on html should always have protocol prefix like http:// or file:/// - in your case so make it like file:///d:/website/images/pic.jpg
. it still does not work, verify the file exists. file name case does not matter in your windows environment.
Upvotes: 0
Reputation: 197609
D:/website/images/pic.jpg
is not a valid URI. The image tag in HTML requires a valid URI for the SRC attribute.
Please see the HTML documentation of your choice (e.g. Mozilla Developer Network (MDN)) and provide a valid URIRFC3986 instead.
Upvotes: 2
Reputation: 95101
Yes it would not work you should use server URL instead D:/website/images/pic.jpg
is a system PATH
echo '<img src="http://example.com/website/images/pic.jpg" alt="Error" />';
Upvotes: 2