Bookstack Attachment Update failing to parse "name" from form-data #3392

Closed
opened 2026-02-05 06:35:07 +03:00 by OVERLORD · 4 comments
Owner

Originally created by @ikubetoomuzik on GitHub (Dec 7, 2022).

Describe the Bug

Unable to use the attachment update API. The response continually says " Undefined array key "name" at /app/www/app/Uploads/AttachmentService.php:163".

Steps to Reproduce

  1. Create a page.
  2. Upload a document to that page.
  3. Note page ID (hereafter known as X).
  4. Note attachment ID (hereafter known as Y).
  5. Create a PUT request to https://$bookstack_url/api/attachments/Y with the following data encoded as "multi-part/form" data:
    { name: $file_name, uploaded_to: X, file: $file_data }

Expected Behaviour

Expect a response similar to:
{
"id": Y,
"name": $file_name,
"extension": "",
"uploaded_to": X,
"external": true,
"order": 2,
"created_by": 1,
"updated_by": 1,
"created_at": "2021-10-20T06:35:46.000000Z",
"updated_at": "2021-10-20T06:37:11.000000Z"
}

Screenshots or Additional Context

I tried enabling DEBUG_MODE in the application but the trace when making this request did not get any larger.

Browser Details

No response

Exact BookStack Version

v22.11

PHP Version

8.0

Hosting Environment

Installed using official docker container on a Rocky Linux 9 host.

Originally created by @ikubetoomuzik on GitHub (Dec 7, 2022). ### Describe the Bug Unable to use the attachment update API. The response continually says " Undefined array key \"name\" at /app/www/app/Uploads/AttachmentService.php:163". ### Steps to Reproduce 1. Create a page. 2. Upload a document to that page. 3. Note page ID (hereafter known as X). 4. Note attachment ID (hereafter known as Y). 5. Create a PUT request to https://$bookstack_url/api/attachments/Y with the following data encoded as "multi-part/form" data: { name: $file_name, uploaded_to: X, file: $file_data } ### Expected Behaviour Expect a response similar to: { "id": Y, "name": $file_name, "extension": "", "uploaded_to": X, "external": true, "order": 2, "created_by": 1, "updated_by": 1, "created_at": "2021-10-20T06:35:46.000000Z", "updated_at": "2021-10-20T06:37:11.000000Z" } ### Screenshots or Additional Context I tried enabling DEBUG_MODE in the application but the trace when making this request did not get any larger. ### Browser Details _No response_ ### Exact BookStack Version v22.11 ### PHP Version 8.0 ### Hosting Environment Installed using official docker container on a Rocky Linux 9 host.
OVERLORD added the 🐛 Bug label 2026-02-05 06:35:07 +03:00
Author
Owner

@ssddanbrown commented on GitHub (Dec 7, 2022):

Hi @ikubetoomuzik,
You might be hitting the issue reported here. Some context is in my linked comment. As per that comment, You could try using a POST request and provide a _method: 'PUT' parameter. If that does not work, it would help to have some insight into the code being used to send this request.

@ssddanbrown commented on GitHub (Dec 7, 2022): Hi @ikubetoomuzik, You might be hitting the [issue reported here](https://github.com/BookStackApp/BookStack/issues/3666#issuecomment-1226105962). Some context is in my linked comment. As per that comment, You could try using a POST request and provide a `_method: 'PUT'` parameter. If that does not work, it would help to have some insight into the code being used to send this request.
Author
Owner

@ikubetoomuzik commented on GitHub (Dec 7, 2022):

Hello @ssddanbrown

Thank-you so much for the quick response. Adding _method=PUT did get things working correctly again. Sorry to bother with something that is already reported, I am not great with searching through GitHub issues.

@ikubetoomuzik commented on GitHub (Dec 7, 2022): Hello @ssddanbrown Thank-you so much for the quick response. Adding _method=PUT did get things working correctly again. Sorry to bother with something that is already reported, I am not great with searching through GitHub issues.
Author
Owner

@ssddanbrown commented on GitHub (Dec 7, 2022):

Happy that worked, No worries at all, It's an awkward issue that shouldn't really be there TBH but I've been split on approaches to fixing it. I might need to document the workaround until I land on a solution.

@ssddanbrown commented on GitHub (Dec 7, 2022): Happy that worked, No worries at all, It's an awkward issue that shouldn't really be there TBH but I've been split on approaches to fixing it. I might need to document the workaround until I land on a solution.
Author
Owner

@ikubetoomuzik commented on GitHub (Dec 7, 2022):

Yeah a small comment in the API docs would be perfect. I don't have much in the way of PHP knowledge but if you have a solution you want to try I have some free time in the evenings to attempt implementing/testing it myself.

@ikubetoomuzik commented on GitHub (Dec 7, 2022): Yeah a small comment in the API docs would be perfect. I don't have much in the way of PHP knowledge but if you have a solution you want to try I have some free time in the evenings to attempt implementing/testing it myself.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#3392