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);