#File form field not being added to useForm object

1 messages · Page 1 of 1 (latest)

lethal garnet
#

Following the file upload docs (https://inertiajs.com/file-uploads), I have the following field

<text-input type="file" label="Documentation" id="my-file" @input="form.my_file = $event.target.files[0]"
                                class="w-full max-w-xs file:bg-indigo-600 file:rounded-md file:text-white file:p-2"/>

where <text-input> is the input borrowed from PingCRM (https://github.com/inertiajs/pingcrm/blob/master/resources/js/Shared/TextInput.vue) and this in useForm()

const form = useForm({
...
    my_file: null
})

However, when I upload a file to that field, the value is not written to the form object (as viewed in Vue dev tools). What do I need to do to get it to work?

boreal gorge
#

You're text-input looks fine. Are you using post method when submitting the form?

<input type="file" @input="form.my_file = $event.target.files[0]">
compact snow