So I'm trying to validate the uploaded image to be only of this type mimes: jpeg, jpg, png
but the problem is if I put the code like this
'photos' => 'required|array|max:5|mimes:jpeg,jpg,png', 'photos.*' => 'mimes:jpeg,jpg,png',
it validates as expected like this The image must be a file of type:jpg,jpeg,png only
, but even if I upload the jpg or png file still shows The image must be a file of type:jpg,jpeg,png only
. And if I put the code like this
'photos' => 'required|array|max:5', 'photos.*' => 'mimetypes:image/jpeg,image/png,image/jpg',
It does not validate so I can even upload a video, psd, and other files which are not of this type mimes:jpeg,jpg,png
. How can I validate the uploaded file to be only of this type mimes:jpeg,jpg,png
?
Controller
$this->validate(
$request,
[
'photos' => 'required|array|max:5',
'photos.*' => 'mimetypes:image/jpeg,image/png,image/jpg',
]);
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire