varovas's avatar

Vue.js 2 File upload doesn't work on patch method

Hi guys,

I have an issue with Vue 2 and Laravel 5.3. The issue is that when I upload file on POST method, everything works fine, code below:

    uploadProfilePicture(event) {
            var input = event.target;
                        
                var form = new FormData()
                form.append('picture', input.files[0]);
                axios.post('/pictures/add', form)
                .then(resp => {
                       this.successDataSave(resp.data)
                 })
                 .catch(error => this.errorDataSave(error));
         }

But when I do the same thing on PATCH method, dd($request->all()) response is "[]". PATCH method code below:

    uploadProfilePicture(event) {
            var input = event.target;
                        
                var form = new FormData()
                form.append('picture', input.files[0]);
                axios.patch('/pictures/{picture}/update)
                .then(resp => {
                       this.successDataSave(resp.data)
                 })
                 .catch(error => this.errorDataSave(error));
         }

Maybe anyone knows how to solve this issue?

0 likes
1 reply
GuntarV's avatar

Just lost a half a day trying to figure out why file is uploading in one form but not the other form. The other form is patch/update. @varovas , did you figured it out?

Please or to participate in this conversation.