Does your HTML form include the attribute enctype="multipart/form-data"?
https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/enctype
Hello, I'm building an admin dashboard form to register new users, which includes a profile image upload feature. However, I'm encountering a problem where uploading an image file (Aron.png) continues to fail validation
Illuminate\Support\ViewErrorBag {#593 ▼
#bags: array:1 [▼
"default" =>
Illuminate\Support
\
MessageBag
{#587 ▼
#messages: array:1 [▼
"profile_image" => array:3 [▼
0 => "The profile image field must be an image."
1 => "The profile image field must be a file of type: image/png, image/jpeg."
2 => "The profile image field has invalid image dimensions."
]
]
#format: ":message"
}
]
}
public function rules(): array
{
return [
'profile_image' => 'required|image|mimetypes:image/png,image/jpeg|max:2048|dimensions:min_width=300,min_height=300'
];
}
@minaremonshaker You can inject PHP values in the virtual host config of whatever web server you're using. So you can customize the config for specific sites if you want to avoid changing php.ini. Not sure how to do that with the PHP development server, though.
Is the error actually coming from your web server, or is it a validation error from Laravel? Did you try removing the max:2048 rule to see if that's causing it? You didn't include file as a validation rule, which might make Laravel use the max rule incorrectly. I don't remember if using image is enough.
Please or to participate in this conversation.