Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. FileUploadSanitizeNameEvent.php

function FileUploadSanitizeNameEvent::setFilename

Sets the filename.

Parameters

string $filename: The filename to use for the uploaded file.

Return value

$this

Throws

\InvalidArgumentException Thrown when $filename contains path information.

1 call to FileUploadSanitizeNameEvent::setFilename()
FileUploadSanitizeNameEvent::__construct in core/lib/Drupal/Core/File/Event/FileUploadSanitizeNameEvent.php
Constructs a file upload sanitize name event object.

File

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

Class

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

Namespace

Drupal\Core\File\Event

Code

public function setFilename(string $filename) : self {
    if (dirname($filename) !== '.') {
        throw new \InvalidArgumentException(sprintf('$filename must be a filename with no path information, "%s" provided', $filename));
    }
    $this->filename = $filename;
    return $this;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal