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

AlexDFCH's avatar

Uploading some pictures by Vue & Inertia.

Hi,

I'm a noob here :)

It's may be pretty simple for you but took my time for 7 hours!

Uploading a pic by Inertia upload file and useForm is simple but when I add the second file input it just accept first one from me.

<script setup>

const form = useForm({
    name: '',
    pics: [],
});


const submit = () => {
    form.post(route('stuff.store'));
}
</script>

<template>
    <input
    type="file"
    @input="form.pics[0] = $event.target.files[0]"/>

    <InputError class="mt-2" :message="form.errors.pics" />

    <div v-if="form.progress" class="mt-2 w-full rounded-full">
        <div class="bg-blue-600 text-xs font-medium text-blue-100 text-center p-0.5 leading-none rounded-full" :width="form.progress.percentage"> %{{ form.progress.percentage }}</div>
    </div>

    <input
    type="file"
    @input="form.pics[1] = $event.target.files[1]"/>

    <InputError class="mt-2" :message="form.errors.pics" />

    <div v-if="form.progress" class="mt-2 w-full rounded-full">
        <div class="bg-blue-600 text-xs font-medium text-blue-100 text-center p-0.5 leading-none rounded-full" :width="form.progress.percentage"> %{{ form.progress.percentage }}</div>
    </div>
</template>

And when I use dd() at the back-end I see the:

array:2 [▼ // app/Http/Controllers/Admin/Profile/ProfileController.php:90
  1 => null
  0 => Illuminate\Http\UploadedFile {#444 ▶}
]

I just need to get all my files at the back-end. Would you tell what I should to do?

Thank you.

0 likes
2 replies
Niush's avatar
Niush
Best Answer
Level 50

The 2nd input field has a small typo. Should be form.pics[1] = $event.target.files[0] as the file is in zeroth index.

You can also do a single <input type="file" multiple ...> if applicable in your app. That allows uploading multiple files in single input field.

1 like
AlexDFCH's avatar

@Niush I cant believe I had a headache today for a simple typo like that.

Thank you my friend for your help.

Please or to participate in this conversation.