First, i'd like to show you my directories

--themes
  -- images
      -img1.jpg
  -index.php
-index.php

My index.php (root) :

<?php
require_once '/themes/index.php';
?>

And, the index.php in the template :

<!DOCTYPE html>
<html>
<head>
<title>Test</title>
</head>
<body>
<img src="images/img1.jpg">
</body>
</html>

I think it will load themes>>images>>img1.jpg
But, it loads images>>img1.jpg which not exists.
So, I use the dirname
<img src="<?php echo __DIR__ . '/';?>images/img1.jpg">
But, instead of localhost, it use the C: directory which is forbidden

Can you tell me how to solve the problem ?

Recommended Answers

All 2 Replies

Do the folowing steps:

1) in index.php

<?php
require_once 'themes/index.php';
?>

2)

<!DOCTYPE html>
<html>
<head>
<title>Test</title>
</head>
<body>
<img src="images/img1.jpg">
</body>
</html>

OR

try this

3) <!DOCTYPE html>
<html>
<head>
<title>Test</title>
</head>
<body>
<img src="../images/img1.jpg">
</body>
</html>

http://<?php echo $_SERVER['HTTP_HOST']; ?>/images/img1.jpg

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.