Search code examples
phppathserver-side-includes

php include from index.html


I'm trying to use php include to include articles on a web page... My file structure looks like this:

  1. /Articles
    • /articles
      • App_Template.html
    • /tags
      • /new
        • index.html
    • /including
      • File.html

In App_Template.html I have the piece of code:

<?php include("../including/File.html"); ?>

Which works fine and displays the correct article when you access App_Template.html, However the code:

<?php include(".../including/File.html"); ?>

Within index.html in the new folder doesn't work and throws these errors:

Warning: include(.../including/File.html) [function.include]: failed to 
open stream: No such file or directory in 
/home/a1696768/public_html/articles/tags/new/index.html on line 79


Warning: include() [function.include]: Failed opening
 '.../including/File.html' for inclusion 
(include_path='.:/usr/lib/php:/usr/local/lib/php') 
in /home/a1696768/public_html/articles/tags/new/index.html on line 79

I've tried searching around to find a reason for this but cannot however find any reason as to why this isn't working here but is in App_Template.html, the only thing I can possibly imagine is it's something to do with the fact the second case is an index.html?


Solution

  • You can't use three dots ... in paths, it's either .. for one level up or . for the current level. If you want to go 2 folders/levels up, use ../../yourfile.