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

Breadcrumb

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

function FileFormField::setErrorCode

Sets the PHP error code associated with the field.

Parameters

int $error The error code (one of UPLOAD_ERR_INI_SIZE, UPLOAD_ERR_FORM_SIZE, UPLOAD_ERR_PARTIAL, UPLOAD_ERR_NO_FILE, UPLOAD_ERR_NO_TMP_DIR, UPLOAD_ERR_CANT_WRITE, or UPLOAD_ERR_EXTENSION):

Throws

\InvalidArgumentException When error code doesn't exist

File

vendor/symfony/dom-crawler/Field/FileFormField.php, line 28

Class

FileFormField
FileFormField represents a file form field (an HTML file input tag).

Namespace

Symfony\Component\DomCrawler\Field

Code

public function setErrorCode(int $error) : void {
    $codes = [
        \UPLOAD_ERR_INI_SIZE,
        \UPLOAD_ERR_FORM_SIZE,
        \UPLOAD_ERR_PARTIAL,
        \UPLOAD_ERR_NO_FILE,
        \UPLOAD_ERR_NO_TMP_DIR,
        \UPLOAD_ERR_CANT_WRITE,
        \UPLOAD_ERR_EXTENSION,
    ];
    if (!\in_array($error, $codes)) {
        throw new \InvalidArgumentException(\sprintf('The error code "%s" is not valid.', $error));
    }
    $this->value = [
        'name' => '',
        'type' => '',
        'tmp_name' => '',
        'error' => $error,
        'size' => 0,
    ];
}

API Navigation

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