Javascript Upload Photos, Logic

This is more a javascript question than anything..
I have an image selector (minimum 3) that runs CountAndUploadPhotos JSquery which looks like this:

for (let i = 0; i < imageInput1.files.length; i++) {
  const file = imageInput1.files[i];

  const base64 = await utils.getDataByObjectURL(imageInput1.value[i]);

  const imageData = {
  data: base64.slice(base64.indexOf(',') + 1),
  size: file.size,
  height: file.height,
  width: file.width
};

  UploadFile.trigger({
    additionalScope: {
      data: imageData.data
    },
    onSuccess: function (data) {
      imageInput1.files[i].clearValue();
      imageInput1.value[i].clearValue();
    }
  });

}
imageInput1.clearValue();

UploadFile is a REST API which uploads the base64 data to another server.
The problem I am experiencing is, technicians in the field will take photos, select them and press the button which triggers CountAndUploadPhotos, but sometimes, depending on how great their cellular service is, the server will receive any random number of the photos (minimum 3, maximum 4). Sometimes one, sometimes two, generally all of them. But I am having difficulty replicating this back in the office.

Seems like I need to have a try and catch or maybe an else statement to prompt them when a file fails to upload. I do know that the server is not logging these failed attempts, so in other words, the app is not sending the request (or the server would see it). So, I see the successful file uploads, but that's it.

Wondering if there is a way to make sure the photos get uploaded, and worst case, prompt the user that a file failed to upload. Best case, keep trying until the device gets good service.

Any ideas would be appreciated, as I'm not a javascript wiz.
Thanks!