0
  1. List item

I have a dircetory Security in which there is a file index.html and another folder security which contains docs folder and in docs folder there is file banner.html. I want to add banner.html through in index.html but I am not being able to understand which pathe to use.

Security-> index.html and security folder-> docs-> banner.html. I want to add banner.html in index.html. Please any Idea? I shall be very thankful for any help.

My directory and file structure is

  • Security
    • index.html
    • security
      • Docs
        • banner.html

Root folder is Security with capital S and inside it are index and security with small s and security contains Docs and Docs contains banner.html and I want to add banner.html in index.html

  • If all your files are `.html`, what does this have to do with PHP? Also, could you please show a graphical representation of your directory structure, eg a screenshot from Explorer / Finder? ASCII art is fine too – Phil Oct 12 '18 at 04:37
  • Sorry I do not know how to take screen shots of nested folders. – Arslan Khan Oct 12 '18 at 04:50
  • If all files are html and not php then how to reference banner.html in index.html – Arslan Khan Oct 12 '18 at 04:51

1 Answers1

1

I see that all your files are HTML however you have added the PHP tag to your comment, so my solution will be written PHP. So if I am understanding correctly you folder structure follows:

  • Security
    • Index.php
    • security
      • Docs
        • Banner.php

So in your index.php file you can place

<?php require __DIR__ . 'security/Docs/banner.php'; ?>

or

<?php include __DIR__ . 'security/Docs/banner.php'; ?>

Read more about Require, Include and DIR

Tom Dickson
  • 540
  • 6
  • 19
  • Would be much better if you prefix those paths with `__DIR__`, just in case `index.php` is included from somewhere else – Phil Oct 12 '18 at 04:51
  • Tom Tanks for your kind response. I have elaborated my directory structure. could you please review your answer with this directory structure. – Arslan Khan Oct 12 '18 at 05:19
  • 1
    @ArslanKhan try figuring out for yourself, I will update my answer as well though mate! – Tom Dickson Oct 12 '18 at 05:21
  • @ArslanKhan No worries, if this has solved your problem can you please mark my answer as the solution. – Tom Dickson Oct 12 '18 at 06:22