Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

seedphrase's avatar

File upload list inertia

Hey,

I want to upload a list of files in term of the role of user, I am using laravel 10 , inertia 1 and vue 3

<div class="col-span-6 sm:col-span-6">
<label class="block text-sm font-medium text-gray-700">Documents</label>
    <div
       v-for="documentType in attrs.documentTypes"
        :key="documentType.code"
         class="mt-2 my-4 flex justify-center rounded-md border-2 border-dashed border-slate-300 px-6 pt-5 pb-6" >
                <div class="text-center space-y-1">
                      <font-awesome-icon
                      class="fa-lg fa-fw"
                        icon="fa-light fa-paperclip"
                                        />
                       <div class="flex text-sm text-slate-600">
                           <label
                     class="relative cursor-pointer rounded-md bg-white font-medium text-amber-500 focus-within:outline-none focus-within:ring-amber-400 focus-within:ring-offset-2 hover:text-amber-400"
                 for="documents">
                    <span> Ajouter le document : {{ documentType.name }}</span>
                        <input
                       id="documents"
                      class="sr-only"
                    name="documents"
                  type="file"
                     @input="form.documents = $event.target.files"  >
                       </label>
                      </div>
                      <p class="text-xs text-gray-500">
                       PDF jusqu'à 4MB
                        </p>
                         </div>
                    </div>
                    </div>

My request contains just one file, the last one I upload

"documents" => array:1 [▼
    0 => Illuminate\Http\UploadedFile {#1624 ▶}
  ]
0 likes
4 replies
Sergiu17's avatar

try to add

<input name="documents[]" <--square brackets
tykus's avatar

@@foobar You need the multiple attribute on the file input if you want to upload more than one file

Please or to participate in this conversation.