title: Ajax file upload not working in Chrome
body: <p>I tested this script in Safari, and there it works, but I tried in Chrome, and there it does not work, and doesn't print the <code>$status</code>. What's the problem?</p>
  
  <p>HTML file:</p>
  
  <pre><code>&lt;script src="https://code.jquery.com/jquery-3.1.1.min.js"&gt;&lt;/script&gt;
  &lt;span id="success"&gt;&lt;/span&gt;
  &lt;form id="upload" method="post" enctype="multipart/form-data"&gt;
      &lt;input type="text" name="username" id="username"&gt;
      &lt;input type="file" name="imagefile" id="imagefile"&gt;
      &lt;input type="submit" name="uploadsubmit" id="uploadsubmit"&gt;
  &lt;/form&gt;
  
  &lt;script&gt;
  
  $(document).ready(function(){
  
      $('#upload').on('submit', function(e) {
          e.preventDefault();
  
          var username = $('#username').val();
          if (username == '') {
              alert("Empty!");
          } else {
              $.ajax({
                  url: "upload.php",
                  type: "POST",
                  data: new FormData(this),
                  contentType: false,
                  processData: false,
                  success: function(data) {
                      $('#success').html(data);
                      alert("Success!");
                  }
              });
          }
      });
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>PHP file:</p>
  
  <pre><code>&lt;?php  
  
  $connect = mysqli_connect("localhost", "root", "", "db");
  $con=mysqli_connect("localhost","root","","db");
  if (mysqli_connect_errno())
  {
      echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
  
  $status = '';
  
  if(isset($_POST['uploadsubmit'])) {
  
      $username = $_POST["username"];
      if($_FILES['imagefile']['name'] != '') {
  
          $target = "/images";
          $target = $target . basename($_FILES['imagefile']['name']);
          if (move_uploaded_file($_FILES['imagefile']['tmp_name'], $target)) {
  
              mysqli_query($con,"SELECT * FROM users");
              mysqli_query($con,"INSERT INTO users (username,images) 
              VALUES ('".$username."','".$target."')");
  
              mysqli_close($con);
  
              $status = "Successfull upload with image!";
              $imagefile = pathinfo($target, PATHINFO_EXTENSION);
              $check = getimagesize($target);
              if ($check !== false) {
                  echo "This file is image - " . $check["mime"] . ".&lt;br&gt;";
                  $uploadOk = 1;
              } else {
                  echo "This file is not image!";
                  $uploadOk = 0;
              }
          } else {
              $status = "Sorry, we have problem!";
          }
      } else {
          mysqli_query($con,"SELECT * FROM users");
          mysqli_query($con,"INSERT INTO users (username,images) 
          VALUES ('".$username."','no')");
  
          mysqli_close($con);
  
          $status = 'Successfull upload without image!';
      }
      echo "Status: {$status}";
  }
  ?&gt;
  </code></pre>