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

eskiesirius's avatar

File Upload Problem

I have a problem in uploading file.. i checked all the sample of upload but it seems that they don't have any remove file function.. so i created my own, my current problem now is that when I tried to remove a key in this.$inertia.form, sometimes it keeps coming back.. example:

data() {
            return {
                form: this.$inertia.form({
                    customer_picture: null,
                    id_picture: null,
                }),
            }
        },
//This is my snippet before submitting the data
//If there is no new file upload, it will remove the key to avoid update
if (this.customer.customer_picture != null) 
                    delete this.form['customer_picture']

if (this.customer.id_picture != null)
					delete this.form['id_picture']

this.form.post(route('customers.update',{ 
                    _method: 'put',
                    customer: this.customer.id,
}))

scenario: there is already an image in the customer_picture field so when i only upload a file at id_picture.. it should remove the customer_picture key to avoid update but what happened was the data of the customer_picture turns to null

0 likes
0 replies

Please or to participate in this conversation.