joedoe's avatar

Inertia File Upload

Anybody knows an example how to use inertia file upload with multiple files and the features of it. Got it working according the official documentation., but only with one uploadfile. https://inertiajs.com/file-uploads

Question is how to handle more than one file and still can use the features of the inertia form. e.g progress bar

0 likes
3 replies
Niush's avatar
Niush
Best Answer
Level 51

You can just push multiple files in an array.

<template>
  <form @submit.prevent="submit">
    <input type="file" @input="form.files = $event.target.files" multiple/>
    <button>Submit</button>
  </form>
</template>

<script setup>
import { useForm } from '@inertiajs/inertia-vue3';

const form = useForm({
  files: [], // <-- array
});

function submit() {
  form.post('/upload')
}
</script>

Then in Laravel access normally by:

$request->file('files'); // <-- array

Please or to participate in this conversation.