For security purposes, all system, images documents are located outside my website root directory. I don’t want to use relative paths because some files are called in difference circumstances, and sometimes they are included inside other files.
I’m looking for an infallible solution to allow me to maintain my system files outside my root directory and access them with absolute paths.
Please read this elaborate explanation:
If I have a page called: “index.php“, it would be located inside the directory “root” (thus accessible to everybody).
This “index.php” would contain a <img src="..." /> to an image file outside the root, in an adjacent directory to “root“, called “images“. Sure I could use src="../images/goody.jpeg" but if I included "index.php"‘s contents in another file, located elsewhere, this would fall short at getting to "goody.jpeg".
So after badgering about paths, could you help me complete this one:
<img src="?
Thank you!
You cannot publicly reference files outside of the public root. That is the whole point of the public root. If ../images/img.jpg works and images/img.jpg is outside of your public root, you have a security issue. The whole point of a public root is to sandbox the public into a confined area of your server. What you are trying to do is allow users to break out of that sandbox.
All public assets (images, css, javascript, etc) should be in the public root or a sub directory under it.