Try to automatically determine an attachment name from a given URL similar to the name of an uploaded file

This commit is contained in:
Jan Böhmer 2023-11-27 17:39:24 +01:00
parent 18db20e511
commit 752cfb3698

View file

@ -141,6 +141,12 @@ class AttachmentFormType extends AbstractType
} }
if (!$file instanceof UploadedFile) { 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; return;
} }