whatwhatwhat whatwhatwhat - 20 days ago 7
HTML Question

Simple website won't open image on desktop using __DIR__

<!DOCTYPE html>
<html>
<head>
<title>This is Hello World page</title>

</head>
<body>
<h1>Hello World</h1>
<img src= "<?php echo __DIR__ .'/pic.png' ?>">
</body>
</html>


I can't figure out why the code isn't showing the image. I made sure to name the file with a
.php
extension and to put both files in the same folder (the desktop).

The eventual goal is to upload an entire folder to a server. Within that folder, there will be an
index.php
file and an image. How can I point the file to the image?

Answer

If pic.png is in the same directory, this will work.

<img src="pic.png">

Also, move the img tag into the body.

Comments