title: php: create directory on form submit?
body: <p>I am wondering what I am doing wrong. I'm inside of PATH and I want to create a folder inside of PATH. I want to check if the folder already exists and, if not, create one. Getting the name of the folder from an input field with name of "dirname".</p>
  
  <pre><code>if (isset($_POST['createDir'])) {
      //get value of inputfield
      $dir = $_POST['dirname'];
      //set the target path ??
      $targetfilename = PATH . '/' . $dir;
      if (!file_exists($dir)) {
          mkdir($dir); //create the directory
          chmod($targetfilename, 0777); //make it writable
      }
  }
  </code></pre>