You are here

public function FileUploadSanitizeNameEvent::__construct in Drupal 10

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/File/Event/FileUploadSanitizeNameEvent.php \Drupal\Core\File\Event\FileUploadSanitizeNameEvent::__construct()

Constructs a file upload sanitize name event object.

Parameters

string $filename: The full filename (with extension, but not directory) being uploaded.

string $allowed_extensions: A list of allowed extensions. If empty all extensions are allowed.

File

core/lib/Drupal/Core/File/Event/FileUploadSanitizeNameEvent.php, line 45

Class

FileUploadSanitizeNameEvent
An event during file upload that lets subscribers sanitize the filename.

Namespace

Drupal\Core\File\Event

Code

public function __construct(string $filename, string $allowed_extensions) {
  $this
    ->setFilename($filename);
  if ($allowed_extensions !== '') {
    $this->allowedExtensions = array_unique(explode(' ', trim(strtolower($allowed_extensions))));
  }
}