gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-05 08:53:46 25 4
gpt4 key购买 nike

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

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

和适当的验证消息:

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.',
];
}

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

最佳答案

经过几个小时的研究,我终于找到了方法:

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

关于php - Laravel 中图像大小规则的自定义验证消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52756480/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com