title: $_POST variables not working with $_FILES and multipart/form-data
body: <p><b>Problem:</b> Whenever I change the <code>enctype</code> on my HTML form to <code>multipart/form-data</code>, <code>$_POST</code> variables do not populate in my php script. Users upload files along with filling out a form, and the files upload to the server but the <code>$_POST</code> variables do not populate.</p>
  
  <p><b>Code:</b></p>
  
  <p>My HTML form that collects the data text/picture.</p>
  
  <p><i>index.php</i></p>
  
  <pre><code>&lt;form name="myForm" METHOD="POST" ACTION="" enctype="multipart/form-data"&gt;
    &lt;input type="text" name="text1" id="text1"&gt;
    &lt;input type="text" name="text2" id="text2"&gt;
    &lt;input type="file" name="filebutton" id="filebutton"&gt;
    &lt;input type="submit" name="submit" id="submit"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>My php script that attempts to update my MySQL database, as well as upload my file on my Ubuntu server is below.</p>
  
  <p><i>upload.php</i></p>
  
  <pre><code>&lt;?php
  $uploaddir = "/var/www/img/pictures/";
  $uploadfile = $uploaddir . basename($_FILES['filebutton']['name']);
  move_uploaded_file($_FILES['filebutton']['tmp_name'], $uploadfile);
  if (isset($_POST['filebutton'])) {  
      $pictureUpdate = ", PICTURE_FILEPATH = '" . $_POST['filebutton'] . "'";
  } else {
      $pictureUpdate = "";
  }
  $connection = mysqli_connect("1.2.3.4","xxxx","xxxx","xxxx") or die("Caonnot connect to database.");
  $update = "UPDATE table SET COLUMN1='" . $_POST['text1'] . "', COLUMN2='" . $_POST['text2'] . "' . $pictureUpdate . " where COLUMN3 = " . $_POST['text1'] . " ";
  $update_sql = mysqli_query($connection, $update) or die("Cannot connect to mysql table. ". $update);
  header("Location: " . $_SERVER['REQUEST_URL'] . "?success=1");
  exit();
  </code></pre>
  
  <p><b>What I've Tried:</b>
  This is the first time doing this, so I'm kinda freestyling here because I cannot seem to get this to work.</p>
  
  <ul>
  <li>Changed the <code>enctype</code> to <code>application/x-www-form-urlencoded</code>. Neither the <code>$_POST</code> or <code>$_FILE</code> data showed up in the <i>upload.php</i> file.</li>
  <li>Removed <code>application/x-www-form-urlencoded</code> altogether. When I do this, my <code>$_POST</code> variables work, but my file does not upload.</li>
  <li>Checked <i>php.ini</i> for <code>post_max_size</code>. Upon searching the internet, I've come across a couple StackOverflow topics concerning similar issues. From what I've gathered, if the file trying to be uploaded exceeds the value in <code>post_max_size</code>, then <code>$_POST</code> variables will not go through. The value in my <i>php.ini</i> file for <code>post_max_size</code> says "8M", and the test file picture being uploaded is 103 KiB.</li>
  </ul>
  
  <p>How do I get <code>$_POST</code> data to work, as well as uploading a file from the same form?</p>