UploadController now only accepts file extensions listed in config.yaml

This commit is contained in:
Ivo Valchev
2019-11-11 14:57:55 +01:00
parent 3a4ebe42ce
commit e06f508908
2 changed files with 6 additions and 1 deletions
+5
View File
@@ -173,4 +173,9 @@ class Config
{
return $this->get('contenttypes/' . $name);
}
public function getFileTypes(): Collection
{
return new Collection($this->get('general/accept_file_types'));
}
}
@@ -72,7 +72,7 @@ class UploadController implements AsyncZone
$uploadHandler->addRule(
'extension',
[
'allowed' => ['jpg', 'jpeg', 'png', 'gif', 'webp', 'svg', 'pdf'],
'allowed' => array_merge($this->config->getMediaTypes()->toArray(), $this->config->getFileTypes()->toArray()),
],
'{label} should be a valid file (jpg, jpeg, png, webp, svg or pdf)',
'Upload file'