From f2aaadac799488dbeecd9d2be340f9763a6e6392 Mon Sep 17 00:00:00 2001 From: Jan Felix Wiebe Date: Sat, 23 Feb 2019 13:40:29 +0100 Subject: [PATCH] fixed js error if no image is attached --- templates/found_item_add.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/templates/found_item_add.php b/templates/found_item_add.php index 26c907b..477cd1d 100644 --- a/templates/found_item_add.php +++ b/templates/found_item_add.php @@ -129,8 +129,10 @@ } var form = new FormData(document.querySelector("#lost_form")); - form.append('title', fileInput.files[0].name); - form.append('image', fileInput.files[0]); + if (fileInput.files.length > 0) { + form.append('title', fileInput.files[0].name); + form.append('image', fileInput.files[0]); + } xhr.send(form);