Answer the question
In order to leave comments, you need to log in
How to validate an array of files in laravel?
Hello.
I have a site component - messages. Where can I attach images and office files.
in the view:
In the controller:
<input type="file" name="attachments[]" multiple>
$request->validate([
"item_id" => "required|exists:items,id",
"message" => "required|max:2000",
"attachments.*" => "nullable|mimes:jpeg,png,gif,docx,xlsx,ppsx",
]);
The attachments.0 must be a file of type: jpeg, png, gif, docx, xlsx, ppsx.
Answer the question
In order to leave comments, you need to log in
Decision. Forgot to mention that this form sends files
enctype="multipart/form-data">
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question