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

Breadcrumb

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

function File::__construct

Same name in this branch
  1. 11.1.x vendor/phpunit/php-code-coverage/src/Node/File.php \SebastianBergmann\CodeCoverage\Node\File::__construct()
  2. 11.1.x vendor/phpunit/php-code-coverage/src/Report/Xml/File.php \SebastianBergmann\CodeCoverage\Report\Xml\File::__construct()
  3. 11.1.x vendor/phpunit/phpunit/src/TextUI/Configuration/Value/File.php \PHPUnit\TextUI\Configuration\File::__construct()
  4. 11.1.x vendor/symfony/mime/Part/File.php \Symfony\Component\Mime\Part\File::__construct()
  5. 11.1.x vendor/symfony/http-foundation/File/File.php \Symfony\Component\HttpFoundation\File\File::__construct()
  6. 11.1.x vendor/squizlabs/php_codesniffer/src/Files/File.php \PHP_CodeSniffer\Files\File::__construct()
  7. 11.1.x core/modules/file/src/Plugin/views/field/File.php \Drupal\file\Plugin\views\field\File::__construct()

Parameters

array<string,mixed>|null $options:

positive-int|string|null $maxSize The max size of the underlying file:

bool|null $binaryFormat Pass true to use binary-prefixed units (KiB, MiB, etc.) or false to use SI-prefixed units (kB, MB) in displayed messages. Pass null to guess the format from the maxSize option. (defaults to null):

string[]|string|null $mimeTypes Acceptable media type(s). Prefer the extensions option that also enforce the file's extension consistency.:

positive-int|null $filenameMaxLength Maximum length of the file name:

string|null $disallowEmptyMessage Enable empty upload validation with this message in case of error:

string|null $uploadIniSizeErrorMessage Message if the file size exceeds the max size configured in php.ini:

string|null $uploadFormSizeErrorMessage Message if the file size exceeds the max size configured in the HTML input field:

string|null $uploadPartialErrorMessage Message if the file is only partially uploaded:

string|null $uploadNoTmpDirErrorMessage Message if there is no upload_tmp_dir in php.ini:

string|null $uploadCantWriteErrorMessage Message if the uploaded file can not be stored in the temporary directory:

string|null $uploadErrorMessage Message if an unknown error occurred on upload:

string[]|null $groups:

array<string|string[]>|string|null $extensions A list of valid extensions to check. Related media types are also enforced ({@see https://symfony.com/doc/current/reference/constraints/File.html#extensi…}):

Overrides Constraint::__construct

See also

https://www.iana.org/assignments/media-types/media-types.xhtml Existing media types

2 calls to File::__construct()
Image::__construct in vendor/symfony/validator/Constraints/Image.php
Image::__construct in vendor/symfony/validator/Constraints/Image.php
1 method overrides File::__construct()
Image::__construct in vendor/symfony/validator/Constraints/Image.php

File

vendor/symfony/validator/Constraints/File.php, line 92

Class

File
Validates that a value is a valid "file".

Namespace

Symfony\Component\Validator\Constraints

Code

public function __construct(?array $options = null, int|string|null $maxSize = null, ?bool $binaryFormat = null, array|string|null $mimeTypes = null, ?int $filenameMaxLength = null, ?string $notFoundMessage = null, ?string $notReadableMessage = null, ?string $maxSizeMessage = null, ?string $mimeTypesMessage = null, ?string $disallowEmptyMessage = null, ?string $filenameTooLongMessage = null, ?string $uploadIniSizeErrorMessage = null, ?string $uploadFormSizeErrorMessage = null, ?string $uploadPartialErrorMessage = null, ?string $uploadNoFileErrorMessage = null, ?string $uploadNoTmpDirErrorMessage = null, ?string $uploadCantWriteErrorMessage = null, ?string $uploadExtensionErrorMessage = null, ?string $uploadErrorMessage = null, ?array $groups = null, mixed $payload = null, array|string|null $extensions = null, ?string $extensionsMessage = null) {
    parent::__construct($options, $groups, $payload);
    $this->maxSize = $maxSize ?? $this->maxSize;
    $this->binaryFormat = $binaryFormat ?? $this->binaryFormat;
    $this->mimeTypes = $mimeTypes ?? $this->mimeTypes;
    $this->filenameMaxLength = $filenameMaxLength ?? $this->filenameMaxLength;
    $this->extensions = $extensions ?? $this->extensions;
    $this->notFoundMessage = $notFoundMessage ?? $this->notFoundMessage;
    $this->notReadableMessage = $notReadableMessage ?? $this->notReadableMessage;
    $this->maxSizeMessage = $maxSizeMessage ?? $this->maxSizeMessage;
    $this->mimeTypesMessage = $mimeTypesMessage ?? $this->mimeTypesMessage;
    $this->extensionsMessage = $extensionsMessage ?? $this->extensionsMessage;
    $this->disallowEmptyMessage = $disallowEmptyMessage ?? $this->disallowEmptyMessage;
    $this->filenameTooLongMessage = $filenameTooLongMessage ?? $this->filenameTooLongMessage;
    $this->uploadIniSizeErrorMessage = $uploadIniSizeErrorMessage ?? $this->uploadIniSizeErrorMessage;
    $this->uploadFormSizeErrorMessage = $uploadFormSizeErrorMessage ?? $this->uploadFormSizeErrorMessage;
    $this->uploadPartialErrorMessage = $uploadPartialErrorMessage ?? $this->uploadPartialErrorMessage;
    $this->uploadNoFileErrorMessage = $uploadNoFileErrorMessage ?? $this->uploadNoFileErrorMessage;
    $this->uploadNoTmpDirErrorMessage = $uploadNoTmpDirErrorMessage ?? $this->uploadNoTmpDirErrorMessage;
    $this->uploadCantWriteErrorMessage = $uploadCantWriteErrorMessage ?? $this->uploadCantWriteErrorMessage;
    $this->uploadExtensionErrorMessage = $uploadExtensionErrorMessage ?? $this->uploadExtensionErrorMessage;
    $this->uploadErrorMessage = $uploadErrorMessage ?? $this->uploadErrorMessage;
    if (null !== $this->maxSize) {
        $this->normalizeBinaryFormat($this->maxSize);
    }
}

API Navigation

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