小编Gev*_*yan的帖子

Laravel 中图像大小规则的自定义验证消息

在我的 CustomFormRequest 文件中,我对图像文件有以下规则:

public function rules() {
        return [
            'image' => 'image|max:2047',
        ];
    }
Run Code Online (Sandbox Code Playgroud)

和适当的验证消息:

public function messages() {
        return [
            'image.image' => 'The type of the uploaded file should be an image.',
            'image.max' => 'Failed to upload an image. The image maximum size is 2MB.',
        ];
    }
Run Code Online (Sandbox Code Playgroud)

但是没有出现最大尺寸规则的消息。显示最大文件大小的默认消息而不是它。我做错了什么?

php validation message rules laravel

2
推荐指数
1
解决办法
3136
查看次数

标签 统计

laravel ×1

message ×1

php ×1

rules ×1

validation ×1