mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-01 14:04:30 +02:00
Try to automatically determine an attachment name from a given URL similar to the name of an uploaded file
This commit is contained in:
parent
18db20e511
commit
752cfb3698
1 changed files with 6 additions and 0 deletions
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue