Level 29
https://inertiajs.com/file-uploads#top
Try this, set the forceFormData: true
this.form.post(this.route("photo.store"), {
forceFormData: true,
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi, guys! In my project i want to upload file using such template (without < />)
template
form @submit.prevent="submit"
label for="photo" value="Photo"
input name="photo" type="file"
button type="submit" :class="{ 'opacity-25': form.processing }" :disabled="form.processing"
Add photo
/button
/form
/template
script
export default {
data() {
return {
form: this.$inertia.form({
photo: '',
})
}
},
methods: {
submit() {
this.form.post(this.route("photo.store"))
}
},
}
/script
And in controller i get
dd($request->photo) // "C:\fakepath\filename.jpg
Could You please prompt how to get $request->photo of UploadedFile class to save it in normal way?
Your file input does not get a file. Try this,
<input type="file" @input="form.photo = $event.target.files[0]" />
Please or to participate in this conversation.