receipt-form: Omit empty uploaded file

If there is no file to be uploaded, then we must not send the value of
the `photo` file input.  Doing so causes two files to be uploaded, the
first one being a zero-byte file with no name, and the second one being
the one we captured from the camera.  The server only uses the first
uploaded file if there are multiple, so the correct file is never used.
bugfix/ci-buildah
Dustin 2025-03-09 21:04:15 -05:00
parent e4ddfbd025
commit e2b14ecf10
1 changed files with 6 additions and 3 deletions

View File

@ -26,10 +26,13 @@ form.addEventListener("submit", async (evt) => {
evt.preventDefault();
btnSubmit.loading = true;
const data = new FormData(form);
if (!inpImage.files?.length) {
data.delete("photo");
const blob = await cameraInput.getBlob();
if (blob) {
data.append("photo", blob, "photo.jpg");
}
}
let r: Response;
try {
r = await fetch("", {