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

silverxjohn's avatar

Request' Input parameter is empty

I'm trying to send a request from my front-end to Laravel. But Laravel doesn't seem to catch it.

Here's my code from client (JS)

return new Promise((resolve, reject) => {
    let formData = new FormData();

    formData.append('attachment', data.attachment);
    formData.append('title', data.title);
    formData.append('content', data.content);
    formData.append('publish_on', data.publish_on);


    axios.put('some/url/1', formData, {
        headers: {
            'Content-Type': 'multipart/form-data'
        }
    }).then(response => {
        resolve(response);
    }).catch(error => {
        reject(error);
    });
});

For testing, I just dump the input from web.php

Route::put('some/url/{something}', function (Request $request) {
    dd(\Input::all());  // returns an empty array
    dd($request->input('title')); // returns a null
});

I'm sure the data has been pass to the server because when I click the Network tab on Chrome Developer Tools, I see it in my Request Payload.

The payload contains:

------WebKitFormBoundaryWmkUAKZRhAmLrvit
Content-Disposition: form-data; name="attachment"; filename="Sample.xlsx"
Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet


------WebKitFormBoundaryWmkUAKZRhAmLrvit
Content-Disposition: form-data; name="title"

The Title
------WebKitFormBoundaryWmkUAKZRhAmLrvit
Content-Disposition: form-data; name="content"

The Content
------WebKitFormBoundaryWmkUAKZRhAmLrvit
Content-Disposition: form-data; name="publish_on"

12-30-2016
------WebKitFormBoundaryWmkUAKZRhAmLrvit--

I need to use FormData here because I'm sending a file. This only happens when updating the resource. The creation is working fine.

PS: I'm using ES2016 syntax

0 likes
3 replies
Snapey's avatar

How big is the file attachment?

silverxjohn's avatar

@Snapey it's just 4kb.

I don't think it's the problem with the server since on my Create form, I can upload any files without a problem. I also configured my php.ini to accept up to 50MB post file.

Also, even if I remove the attachment from the form, the Input::all() is still empty.

Please or to participate in this conversation.