使用文件上传使用ajax和PHP更新图像[重复]

I'm at a bit of a loss. I have a table that is filled based on certain information that can be edited. The last column allows for an image upload to associate with that information. I have no problem passing the text data but I can't get the image file to upload and save correctly. I researched that I need to use Form Data somehow but nothing points to how to send Form Data in addition to the variable I have already created.

I've messed around with different solution but nothing seems to be working properly.

<script type="text/javascript">

    function confirmdata(){
        var status=true;

    $('#newPartTable tr').each(function(){

      var id = $(this).find("td:eq(0)").text();
      var localeid = $(this).find("td:eq(1)").text();

      var ni = $(this).find("#newImage").prop('files')[0];
      var formData = new FormData();
      formData.append('file', ni);


      var data = {

        id : id,
        localeid : localeid,

            };

      $.ajax({
        type:   "POST",
        url:    "confirm.php",
        data:   data,
        async: false,
        success: function() {
          $('.success').fadeIn(200).show();
          $('.error').fadeOut(200).hide();
        }
      });
    });
  }

</script>

Confirm.php

<?php


$conn = new mysqli($host, $username, $password, $db);

$id = $_POST['id'];
$localeid = $_POST['localeid'];


$filetmp = $_FILES["ni"]["tmp_name"];
$filename = $_FILES["ni"]["name"];
$filetype = $_FILES["ni"]["type"];
$filepath = "images/".$filename;

$insert = $conn->prepare("INSERT INTO bogus(bNAME) values(?)");
$insert->bind_param('s', $filepath);
$insert->execute();

?>

I am having it insert into a dummy table until I can see that it's sending the right data to the database. I took out most of the other data I am sending to the PHP page for simplicity.

</div>