title: Warning: mkdir(): File exists
body: <p>The file transferring to my upload folder is working well but I have a warning in <em>mkdir</em>. It says file exist but the picture and folder generates own name. I don't know what warning is determining.</p>
  <pre><code>include 'connect.php';
  
  $dir = substr(uniqid(), -7); // Uniqid for subdirectory
  
  $path = &quot;uploads/$dir/&quot;; // uploads/subdirectory/  // Make directory
  
  $valid_formats = array(&quot;jpg&quot;, &quot;png&quot;, &quot;jpeg&quot;, &quot;kml&quot;);
  
  $max_file_size = 2097152;
  
  $count = 0;
  
  // Loop $_FILES to execute all files
  
  if (!empty($_FILES)) {
      foreach ($_FILES['files']['name'] as $f =&gt; $name) {
          if ($_FILES['files']['error'][$f] == 4) {
              continue; // Skip file if any error found
          }
  
          if ($_FILES['files']['error'][$f] == 0) {
              if ($_FILES['files']['size'][$f] &gt; $max_file_size) {
                  $message[] = &quot;$name is too large!.&quot;;
                  continue; // Skip large files
              } elseif (!in_array(pathinfo($name, PATHINFO_EXTENSION), $valid_formats)) {
                  $message[] = &quot;$name is not a valid format&quot;;
                  continue; // Skip invalid file formats
              } else { // No error found! Move uploaded files
                  mkdir($path, 0700);
                  $ext = pathinfo($_FILES['files']['name'][$f], PATHINFO_EXTENSION);
                  $uniq_name = substr(uniqid(), -5) . '.' . $ext;
                  $dest = $path . $uniq_name;
  
                  if (move_uploaded_file($_FILES[&quot;files&quot;][&quot;tmp_name&quot;][$f], $dest)) {
                      // more logic
                  }
              }
          }
      }
  }
  </code></pre>