Symfony / Component / HttpFoundation / File / UploadedFile;错误代码含义列表在哪里?

时间:2017-02-07 13:23:40

标签: symfony

我正在阅读SYMFONY API doc about UploadedFile

它解释了getErrors():

  

如果上传成功,则返回常量UPLOADERROK。   否则返回其他一个UPLOADERRXXX常量。

我试图搜索 UPLOADERROK UPLOADERRXXX 它没有检索任何相关内容。

查看“[my_symf_project] \ vendor \ symfony \ symfony \ src \ Symfony \ Component \ HttpFoundation \ File \ UploadedFile”的代码我找到了常量名称及其含义:

/**
 * 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);
}

但我无法找到与这些常量相匹配的代码

1 个答案:

答案 0 :(得分:4)

这些是PHP提供的built-in constants