file_exists included files
<p>I'm trying to check if a file exists from within an included file but not sure what the path would be.</p>

<p>Let a draw up the directory structure:</p>

<pre><code>/public_html/
  index.php
  images/pics/pic1.jpg
  subdir1/somefile1.php
  subdir2/somefile2.php
  shared/sharecodefile.php (file of functions that shared amoung all files)
</code></pre>

<p>Firstly in index.php, when i do :</p>

<pre><code>file_exists("images/pics/pic1.jpg")
</code></pre>

<p>This works. However, when including sharecodefile.php. i'm a bit lost as to what dir this file now assumes as it's current dir. if I include this file in index.php,</p>

<pre><code>file_exists("images/pics/pic1.jpg")
</code></pre>

<p>This does not work. I've tried :</p>

<pre><code>file_exists("./images/pics/pic1.jpg"); 
file_exists("../images/pics/pic1.jpg");
file_exists($_SERVER['DOCUMENT_ROOT']."images/pics/pic1.jpg");
file_exists($_SERVER['DOCUMENT_ROOT']."/images/pics/pic1.jpg");
</code></pre>

<p>None seems to work.
To make things worse, I also need to include sharecodefile.php in the other files <code>somefile1.php</code> + <code>somefile2.php</code></p>

<p>Any pointers / explanation of what to do will be much appreciated.</p>
