nyluje
nyluje

Reputation: 3783

Symfony/Component/HttpFoundation/File/UploadedFile ; Where is Error code meaning list?

I am reading SYMFONY API doc about UploadedFile

It explains getErrors() as such:

If the upload was successful, the constant UPLOADERROK is returned. Otherwise one of the other UPLOADERRXXX constants is returned.

I've tried to search UPLOADERROK and UPLOADERRXXX it doesn't retrieve anything relevant.

Looking in the code of "[my_symf_project]\vendor\symfony\symfony\src\Symfony\Component\HttpFoundation\File\UploadedFile" I've found the Constant name and their meaning:

/**
 * Returns an informative upload error message.
 *
 * @return string The error message regarding the specified error code
 */
public function getErrorMessage()
{
    static $errors = array(
        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 = $errorCode === UPLOAD_ERR_INI_SIZE ? self::getMaxFilesize() / 1024 : 0;
    $message = isset($errors[$errorCode]) ? $errors[$errorCode] : 'The file "%s" was not uploaded due to an unknown error.';

    return sprintf($message, $this->getClientOriginalName(), $maxFilesize);
}

But I am not able to find the code matching those constant.

Upvotes: 0

Views: 2476

Answers (1)

xabbuh
xabbuh

Reputation: 5881

These are the built-in constants provided by PHP.

Upvotes: 4

Related Questions