How to upload multiple Files with getUploadedFiles()


#1

Hi

I’m trying to upload multiple files but I see that getUploadedFiles() only gets one file.

This is my code:

 $files = $request->getUploadedFiles();

 var_dump($files);
 die();

And I’m using Postman like this example (https://i.stack.imgur.com/kAIrb.png) and choosing several files

Thanks in advance!


#2

Hi @josvan did you figure this out?


#3

Same thing was happening to me when i had input set like this:
<input type="file" name="gallery" multiple="multiple">
fix was to add “[]” behind name:
<input type="file" name="gallery[]" multiple="multiple">

now getUploadedFiles() shows more than one file,
hope it helps somebody :slight_smile:


#4

You have to set the Content-type of the message as multipart/form-data