A multipart request can contain a text part and an uploaded file with the same field name. Do not depend on $request->all() to preserve both values. Retrieve the file and text input separately, then give them distinct keys before validation.
Last updated: November 16, 2026.
use Illuminate\Support\Facades\Validator;
$upload = $request->file('file');
$metadata = $request->input('file');
$data = Validator::make([
'upload' => $upload,
'metadata' => $metadata,
], [
'upload' => ['required', 'file', 'mimes:pdf', 'max:10240'],
'metadata' => ['nullable', 'json'],
])->validate();
$path = $data['upload']->store('documents');The validation array deliberately renames the two values. That removes ambiguity without trusting the original filename or moving the upload before Laravel has validated it.
Keep request input and files separate
Laravel’s request documentation provides file(), hasFile() and isValid() specifically for uploads. Text values come from input(). Calling the two accessors explicitly is safer than assuming that a merged request array can represent two different multipart parts with one key.
A current Laravel framework issue documents a Laravel 13 behavior change when a text field and upload share a name. The practical fix is not to guess which value wins. Separate the values at the controller boundary, or change the client to send names such as file and file_metadata.
Verify the complete upload path
Use Laravel’s file validation rules for type and size, and generate the stored filename rather than using the client-supplied name as a path. Confirm the configured disk, directory permissions and maximum request limits. If metadata is JSON, validate its structure after decoding instead of inserting it directly into a database.
Add a feature test that sends both multipart parts under the same name and asserts the stored file contents, metadata and database record. Also test a missing file, an invalid upload, oversized content and malformed JSON. This protects the controller if the browser library or framework merge behavior changes again.