I'm currently facing this issue where I want to use the max key when I upload a file. But then it returns a different message. The max key returns the uploaded message instead of the max message. I know I can use the uploaded key but this key is for validation when the file was not successfully uploaded. [Other reference].
Code
public function rules()
{
return [
'image' => 'required|max:2048|file|mimetypes:image/jpg,image/jpeg,image/png'
];
}
public function messages()
{
return [
'image.max' => 'The image file size must not be greater than 2Mb.'
];
}
Expected
The image file size must not be greater than 2Mb.'
Result
The image failed to upload.
image.maxwill only return if the uploaded file size is greater than 2MB not for other wise any other reason! You need to dig deeper and find out why upload is unsuccessful !upload_max_filesize, as @OMiShah said the error is not related to your max validation