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

Breadcrumb

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

function UploadedFile::getErrorMessage

Returns an informative upload error message.

1 call to UploadedFile::getErrorMessage()
UploadedFile::move in vendor/symfony/http-foundation/File/UploadedFile.php
Moves the file to a new location.

File

vendor/symfony/http-foundation/File/UploadedFile.php, line 271

Class

UploadedFile
A file uploaded through a form.

Namespace

Symfony\Component\HttpFoundation\File

Code

public function getErrorMessage() : string {
    static $errors = [
        \UPLOAD_ERR_INI_SIZE => 'The file "%s" exceeds your upload_max_filesize ini directive (limit is %d KiB).',
        \UPLOAD_ERR_FORM_SIZE => 'The file "%s" exceeds the upload limit defined in your form.',
        \UPLOAD_ERR_PARTIAL => 'The file "%s" was only partially uploaded.',
        \UPLOAD_ERR_NO_FILE => 'No file was uploaded.',
        \UPLOAD_ERR_CANT_WRITE => 'The file "%s" could not be written on disk.',
        \UPLOAD_ERR_NO_TMP_DIR => 'File could not be uploaded: missing temporary directory.',
        \UPLOAD_ERR_EXTENSION => 'File upload was stopped by a PHP extension.',
    ];
    $errorCode = $this->error;
    $maxFilesize = \UPLOAD_ERR_INI_SIZE === $errorCode ? self::getMaxFilesize() / 1024 : 0;
    $message = $errors[$errorCode] ?? 'The file "%s" was not uploaded due to an unknown error.';
    return \sprintf($message, $this->getClientOriginalName(), $maxFilesize);
}

API Navigation

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