title: Check if directory exists, make directory
body: <p>I'm having a little trouble with this. Thought it'd be easier, but turning out to frustrate. All I'm trying to do is have a text field where I can type the name of a new directory, check if that directory exists, and if not create it. I have found about 50 other people with almost the exact same code, so thought I had it correct but I keep getting Directory exists as per the "if" statement.</p>
  
  <p>Eventually I want to tie this into my file upload script.</p>
  
  <p>Here is the insert.php</p>
  
  <pre><code>&lt;form action="" method="post" enctype="multipart/form-data" name="form1" id="form1"&gt;
    &lt;p&gt;
      &lt;label for="directory"&gt;Directory:&lt;/label&gt;
      &lt;input value="&lt;?php if ($_POST &amp;&amp; $errors) {
    echo htmlentities($_POST['directory'], ENT_COMPAT, 'UTF-8');
  }?&gt;" type="text" name="directory" id="directory" /&gt;
    &lt;/p&gt;
    &lt;p&gt;
      &lt;input type="submit" name="insert" id="insert" value="insert" /&gt;
    &lt;/p&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>And here is the post.php</p>
  
  <pre><code>try {
  if (isset($_POST['insert'])) {
      $directory = $_POST['directory'];
      $photo_destination = 'image_upload/';
      $path = $photo_destination;
      $new_path = $path . $directory;
      $mode = 0755;
      if(!is_dir($new_path)) {
          echo "The Directory {$new_path} exists";
          } else {
              mkdir($new_path , 0777);
              echo "The Directory {$new_path} was created";
              }
          }
  }
  </code></pre>