title: 'move_uploaded_file(): Unable to move' Multiple Files XAMPP
body: <p>I'm quite new to PHP, i'm trying to make a form to allow a user to upload a html file, a php file and give it a title. </p>
  
  <p>It should use the title to create a new folder to move the two files to.
  Currently it creates the directory with no issues, however it cannot move the uploaded file from the tmp directory. 
  and gives me the following error:</p>
  
  <blockquote>
    <p>Warning: move_uploaded_file(): Unable to move 'C:\xampp\tmp\php2152.tmp' to 'C:\xampp\htdocs\var\uploads\pages\Instagram' in C:\xampp\htdocs\newPage.php on line 15
    Error -htmlUpload</p>
  </blockquote>
  
  <p>heres my HTML form:</p>
  
  <pre><code>&lt;form action="newPage.php" method="post" enctype='multipart/form-data'&gt;
      &lt;label for="pageName"&gt;Enter Page Name: &lt;/label&gt;
      &lt;input type="text" name="pageName" id="pageName" /&gt;
      &lt;br /&gt;
      &lt;label for="pageHTMLUpload"&gt;HTML File: &lt;/label&gt;
      &lt;input type="file" name="pageHTMLUpload" id="pageHTMLUpload" /&gt;
      &lt;br /&gt;
      &lt;label for="pagePHPUpload"&gt;PHP File: &lt;/label&gt;
      &lt;input type="file" name="pagePHPUpload" id="pagePHPUpload" /&gt;
      &lt;br /&gt;
      &lt;center&gt;
          &lt;button class="btn btn-dark" type="submit"&gt;Submit&lt;/button&gt;
      &lt;/center&gt;
  </code></pre>
  
  <p></p>
  
  <p>and heres the corresponding php:</p>
  
  <pre>
  
      $dir = getcwd() . '/var/uploads/pages/';
      $pageName = $dir . $_POST['pageName'];
      if(mkdir($pageName, 0777, true)){
        $filepathHTML = $pageName . basename($_FILES['pageHTMLUpload'['name']]);
        $filepathPHP = $pageName . basename($_FILES['pagePHPUpload']['name']);
        if(move_uploaded_file($_FILES['pageHTMLUpload']['tmp_name'], "$filepathHTML")){
          if(move_uploaded_file($_FILES['pageHTMLUpload']['tmp_name'], "$filepathHTML")){
            $stmt = $conn->prepare("INSERT INTO pages (title, htmlDir, phpDir) VALUES (?,?,?)");
            $stmt->bind_param('sss', $pageName, $filepathHTML, $filepathPHP);
            $stmt->execute();
          }
          else{
            echo "Error -phpUpload";
          }
        }
        else{
          echo "Error -htmlUpload";
        }
      }
      else{
        echo "Error -pagename";
      }
  
  </pre>
  
  <p>I've read that this issue can be caused by incorrect permissions, however I can successfully upload files from another script into a different folder within the var/uploads directory. Is this to do with posting two files at the same time?</p>
  
  <p>edit:
  So I've been adding a few echos to see whats happening; and it seems to be an issue with the basename.</p>
  
  <p>when echoing the result of</p>
  
  <pre><code>$filepathHTML = $pageName . basename($_FILES['pageHTMLUpload'['name']]);
  $filepathPHP = $pageName . basename($_FILES['pagePHPUpload']['name']);
  </code></pre>
  
  <p>I get:</p>
  
  <blockquote>
    <p>HTML:C:\xampp\htdocs/var/uploads/pages/Instagram/
    PHP:C:\xampp\htdocs/var/uploads/pages/Instagram/Gallery.php</p>
  </blockquote>
  
  <p>From the looks of it, it is trying to move a tmp file into pages as the Instagram directory which doesn't work, however the PHP contains the basename of the file, and i'm assuming this is what HTML should do. </p>
  
  <p>Both of my filepath variables are defined in the same process, why does the HTML one not have the filename attached?</p>