From 752cfb3698773bbf621fffde9d4f35833deb9ccb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Mon, 27 Nov 2023 17:39:24 +0100 Subject: [PATCH] Try to automatically determine an attachment name from a given URL similar to the name of an uploaded file --- src/Form/AttachmentFormType.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Form/AttachmentFormType.php b/src/Form/AttachmentFormType.php index 66ebb37c..109c6602 100644 --- a/src/Form/AttachmentFormType.php +++ b/src/Form/AttachmentFormType.php @@ -141,6 +141,12 @@ class AttachmentFormType extends AbstractType } if (!$file instanceof UploadedFile) { + //When no file was uploaded, but a URL was entered, try to determine the attachment name from the URL + if (empty($attachment->getName()) && !empty($attachment->getURL())) { + $name = basename(parse_url($attachment->getURL(), PHP_URL_PATH)); + $attachment->setName($name); + } + return; }