class FileUploadSanitizeNameEvent extends Event (View source)

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

Properties

protected string $filename

The name of the file being uploaded.

protected string[] $allowedExtensions

A list of allowed extensions.

protected bool $isSecurityRename

Indicates the filename has changed for security reasons.

Methods

__construct(string $filename, string $allowed_extensions)

Constructs a file upload sanitize name event object.

string
getFilename()

Gets the filename.

setFilename(string $filename)

Sets the filename.

array
getAllowedExtensions()

Gets the list of allowed extensions.

setSecurityRename()

Sets the security rename flag.

bool
isSecurityRename()

Gets the security rename flag.

void
stopPropagation()

{@inheritdoc}

Details

__construct(string $filename, string $allowed_extensions)

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.

string getFilename()

Gets the filename.

Return Value

string

The filename.

FileUploadSanitizeNameEvent setFilename(string $filename)

Sets the filename.

Parameters

string $filename

The filename to use for the uploaded file.

Return Value

FileUploadSanitizeNameEvent

Exceptions

InvalidArgumentException

array getAllowedExtensions()

Gets the list of allowed extensions.

Return Value

array

The list of allowed extensions.

FileUploadSanitizeNameEvent setSecurityRename()

Sets the security rename flag.

bool isSecurityRename()

Gets the security rename flag.

Return Value

bool

TRUE if there is a rename for security reasons, otherwise FALSE.

void stopPropagation()

{@inheritdoc}

Return Value

void

Exceptions

RuntimeException

See also

SecurityFileUploadEventSubscriber