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
parent
e4ddfbd025
commit
e2b14ecf10
|
@ -26,9 +26,12 @@ form.addEventListener("submit", async (evt) => {
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
btnSubmit.loading = true;
|
btnSubmit.loading = true;
|
||||||
const data = new FormData(form);
|
const data = new FormData(form);
|
||||||
const blob = await cameraInput.getBlob();
|
if (!inpImage.files?.length) {
|
||||||
if (blob) {
|
data.delete("photo");
|
||||||
data.append("photo", blob, "photo.jpg");
|
const blob = await cameraInput.getBlob();
|
||||||
|
if (blob) {
|
||||||
|
data.append("photo", blob, "photo.jpg");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
let r: Response;
|
let r: Response;
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue