Axios/Ajax HTTP patch requests with file not working

Posted 2 years ago by rickbolton

I'm using Axios HTTP requests however, I've also tried using jQuery ajax and getting the same result

let files = || e.dataTransfer.files;
                if (!files.length) {

                let form = new FormData();
                form.append('profile_picture', files[0]);

                axios.patch('/profile', form)
                .then((response) => {

                    headers: {
                        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')

                    url: '/profile',
                    type: 'patch',
                    data: form,
                    cache: false,
                    dataType: 'json',
                    processData: false,
                    contentType: false,
                    success: function(response) {

When it's a PATCH request the file does not appear in the request in Laravel. However, when I change it to POST the file appears correctly. Has anyone come across this and have a way to get this working using PATCH request? Or is it fine to use POST even though I'm updating a record?


Please sign in or create an account to participate in this conversation.

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up


Reply to

Use Markdown with GitHub-flavored code blocks.