PHP - why is_dir returns TRUE when a dir doesn't exist?
<p>My current directory structure is as follows:</p>

<pre><code>C:\xampp\htdocs\PHP_Upload_Image_MKDIR
</code></pre>

<p>In other words, the following directories do NOT exist at all.</p>

<pre><code>C:\xampp\htdocs\PHP_Upload_Image_MKDIR\uploaded
C:\xampp\htdocs\PHP_Upload_Image_MKDIR\uploaded\s002
</code></pre>

<p>The problem is that when I run the following script, the function is_dir always return TRUE.</p>

<p>Based on the manual, <a href="http://us2.php.net/manual/en/function.is-dir.php" rel="nofollow">http://us2.php.net/manual/en/function.is-dir.php</a>
is_dir: Returns TRUE if the filename exists and is a directory, FALSE  otherwise. </p>

<p>Do I miss something here?</p>

<p>Thank you</p>

<blockquote>
<pre><code>$userID = 's002';
$uploadFolder = '/PHP_Upload_Image_MKDIR/uploaded/';
$userDir = $uploadFolder . $userID;
echo '&lt;br/&gt;$userDir: ' . $userDir . '&lt;br/&gt;';

if ( is_dir ($userDir))
{
  echo "dir exists"; // always hit here!!!
}
else 
{
  echo "dir doesn't exist";
}

mkdir($userDir, 0700);
</code></pre>
</blockquote>

<pre><code>C:\xampp\htdocs\PHP_Upload_Image_MKDIR&gt;dir /ah
 Volume in drive C is System
 Volume Serial Number is 30B8-2BB2

 Directory of C:\xampp\htdocs\PHP_Upload_Image_MKDIR

File Not Found

C:\xampp\htdocs\PHP_Upload_Image_MKDIR&gt;


//////////////////////////////////////////////////////////
</code></pre>

<p>Based on Artefacto's comments:</p>

<pre><code>Here is the output of C:\PHP_Upload_Image_MKDIR\uploaded\s005
 echo '&lt;br/&gt;' . realpath($userDir) . '&lt;br/&gt;';
</code></pre>

<p>Thank you for the solutions.</p>

<p>Best wishes</p>
