It keeps calling ajax, on first time it works fine then on second time uploads 2 times the first time then the second time, on third call it uploads 3 times, it just keeps increasing and uploading older images.
      $(".imageUploadIcon").on('click', function(ev){
      var readyflag = true;
      if (readyflag == true){
        ev.preventDefault();
        var fd = new FormData();
          var imgid = $(this).data('img-id');
          $('#imgupload').click();
          var uid = <?php echo $_GET['user']; ?>;
          fd.append('uid', uid);
          fd.append('imgid', imgid);
        $("#imgupload").change(function (){
         var image = $('#imgupload')[0].files[0];
         fd.append('image',image);
        $("#img"+imgid).attr('src','img/loader.gif');
            $.ajax({
                type: "POST",
                url: "php/usrIMG.php",
                data: fd,
                processData: false,
                contentType: false,
                success: function (data) {
                  $("#img"+imgid).attr('src','../../'+data);
                  Materialize.toast('Image uploaded successfully!', 4000);
                  eadyflag = false;
                  imgid = '';
                  image = '';
                  $('#imgupload').val("");
              }
            });
      });
    }
  });
 
    