Level 12
Check if you added multipart enctype on your html form
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have a multiple file input field:
<input type="file" id="documents" name="documents[]" multiple>
In ProjecRequest:
$rules = [
'documents.*' => 'mimes:doc,pdf,jpeg,bmp,png|max:20000',
];
return $rules;
In ProjectController@store:
public function store(ProjectRequest $request)
{
$project = Project::create([
/*key=>value removed to keep the question clean*/
]);
foreach ($request->documents as $document) {
$filename = $document->store('documents');
Document::create([
'project_id' => $project->id,
'filepath' => $filename
]);
}
return redirect()->back();
}
But when I try to upload a png or pdf I get the following validation error:
The documents.0 must be a file of type: doc, pdf, jpeg, bmp, png.
Please or to participate in this conversation.