Question: I want to show the custom validation error message if user upload an image size of more than 4 MB. However, once submitted with an image of like above 4MB, it shows the default error message : "The file name failed to upload.". Below is my code in the controller:

```
$messages = [
            'fileName' => 'Image maximum size exceed. ',
];

$validator = Validator::make($request->all(), [
            'fileName' => 'max:4096', 
        ], $messages);

if ($validator->fails()) {
            return redirect()->back()->withErrors($validator->errors());
        }

```

Here is the HTML code in the blade file:

```
<input type="file" name="fileName">

```

Answer: 
I know this is an old question but I have to post this answer here. This was what worked for me

```
$messages = [
            'fileName.uploaded' => 'Image maximum size exceed. ',
];

```
I used this line:

```
return redirect()->back()->withErrors($validator->customMessages);

```

and it solved the problem.