title: How to create a folder and upload the selected files in that folder in PHP?
body: <p>I am trying to create a folder with user given name and to upload the selected files into that folder, but I am only able to create the folder and not able to move the uploaded files into that folder. Please help me.</p>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt;
          &lt;title&gt;File upload&lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;form action="#" method="post" enctype="multipart/form-data"&gt;
              &lt;input type="file" name="file"&gt;
              &lt;br&gt;
              &lt;label&gt;Enter the folder name:&lt;/label&gt;
              &lt;input type="text" name="foldername"&gt;
              &lt;br&gt;
              &lt;input type="submit" name="submit" value="Upload"&gt;
  
          &lt;/form&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  
  &lt;?php
      if(isset($_POST['submit']))
      {
          $foldername=$_POST['foldername'];
  
          $filename=$_FILES['file']['name'];
  
          $tmpname=$_FILES['file']['tmp_name'];
  
          $result=mkdir($foldername);
  
          if($result)
          {
              echo "created folder";
          }
          else
          {
             echo "not created folder";
          }
          $row=move_uploaded_file($tmpname,"$result/$filename");
          if($row)
          {
              echo "succesffully uploaded";
          }
          else
          {
              echo "failed to upload";
          }
      }
  ?&gt;
  </code></pre>