Bookstack cannot handle 'large' files #5220

Open
opened 2026-02-05 09:49:25 +03:00 by OVERLORD · 6 comments
Owner

Originally created by @kobaz on GitHub (Mar 13, 2025).

Describe the Bug

Update related settings to allow large files in apache, php, bookstack
Upload large file
Upload fails

Steps to Reproduce

  1. Update related settings to allow large files in apache, php, bookstack
  2. bookstack
    FILE_UPLOAD_SIZE_LIMIT=4096
  3. apache
    LimitRequestBody 4294967296
  4. php
    memory_limit = 4096M
    post_max_size = 4096M
    upload_max_filesize = 4096M

phpinfo() validates the above settings are loaded.

  1. Upload large file (This one is Content-Length 975151309)

  2. Observe error:
    attachments/upload?uploaded_to=377
    422 (Unprocessable Content)

I'm seeing that files that go over the apache max request size will result in
attachments/upload?uploaded_to=377
net::ERR_CONNECTION_RESET 413 (Request Entity Too Large)

But If you're within the apache max request size, then you get the 422 error. Is bookstack throwing this? It's hard to tell, since bookstack doesn't seem to write any log files.

Expected Behaviour

Expected upload to be successful.

Screenshots or Additional Context

No response

Browser Details

No response

Exact BookStack Version

v25.02

Updates Since Originally posting the bug:
I made a quick test.php that accepted any type of upload.
I uploaded the exact same file with 'Content-Length 975151309' and the test upload returned 200 OK

It does seem to point to bookstack doing the rejection of: 422 (Unprocessable Content)

Originally created by @kobaz on GitHub (Mar 13, 2025). ### Describe the Bug Update related settings to allow large files in apache, php, bookstack Upload large file Upload fails ### Steps to Reproduce 1. Update related settings to allow large files in apache, php, bookstack 2. bookstack FILE_UPLOAD_SIZE_LIMIT=4096 3. apache LimitRequestBody 4294967296 4. php memory_limit = 4096M post_max_size = 4096M upload_max_filesize = 4096M phpinfo() validates the above settings are loaded. 5. Upload large file (This one is Content-Length 975151309) 6. Observe error: attachments/upload?uploaded_to=377 422 (Unprocessable Content) I'm seeing that files that go over the apache max request size will result in attachments/upload?uploaded_to=377 net::ERR_CONNECTION_RESET 413 (Request Entity Too Large) But If you're within the apache max request size, then you get the 422 error. Is bookstack throwing this? It's hard to tell, since bookstack doesn't seem to write any log files. ### Expected Behaviour Expected upload to be successful. ### Screenshots or Additional Context _No response_ ### Browser Details _No response_ ### Exact BookStack Version v25.02 Updates Since Originally posting the bug: I made a quick test.php that accepted any type of upload. I uploaded the exact same file with 'Content-Length 975151309' and the test upload returned 200 OK It does seem to point to bookstack doing the rejection of: 422 (Unprocessable Content)
OVERLORD added the 🐛 Bug label 2026-02-05 09:49:25 +03:00
Author
Owner

@ssddanbrown commented on GitHub (Mar 13, 2025):

Hi @kobaz,

The status code indicates the request validation is failing (which just checks the page id is valid, and the file upload is a file within the set size limit).

Can you confirm the full exact output of running ls -alh bootstrap/cache from your BookStack install?

@ssddanbrown commented on GitHub (Mar 13, 2025): Hi @kobaz, The status code indicates the request validation is failing (which just checks the page id is valid, and the file upload is a file within the set size limit). Can you confirm the full exact output of running `ls -alh bootstrap/cache` from your BookStack install?
Author
Owner

@kobaz commented on GitHub (Mar 20, 2025):

intellasoft-support {/opt/BookStack} root# ls -al bootstrap/cache/
total 40K
drwxr-xr-x 2 bookstack bookstack 4.0K Mar 13 14:56 .
drwxr-xr-x 3 bookstack bookstack 4.0K Oct 25  2023 ..
-rwxr-xr-x 1 bookstack bookstack   14 Oct 25  2023 .gitignore
-rwxr-xr-x 1 root      root       802 Mar 13 14:56 packages.php
-rwxr-xr-x 1 root      root       22K Mar 13 14:56 services.php
@kobaz commented on GitHub (Mar 20, 2025): ``` intellasoft-support {/opt/BookStack} root# ls -al bootstrap/cache/ total 40K drwxr-xr-x 2 bookstack bookstack 4.0K Mar 13 14:56 . drwxr-xr-x 3 bookstack bookstack 4.0K Oct 25 2023 .. -rwxr-xr-x 1 bookstack bookstack 14 Oct 25 2023 .gitignore -rwxr-xr-x 1 root root 802 Mar 13 14:56 packages.php -rwxr-xr-x 1 root root 22K Mar 13 14:56 services.php ```
Author
Owner

@ssddanbrown commented on GitHub (Mar 21, 2025):

Okay, what's the output of running the below from your BookStack install directory?:

php artisan tinker --execute="dd(config('app.upload_limit'))"
@ssddanbrown commented on GitHub (Mar 21, 2025): Okay, what's the output of running the below from your BookStack install directory?: ```bash php artisan tinker --execute="dd(config('app.upload_limit'))" ```
Author
Owner

@kobaz commented on GitHub (Mar 24, 2025):

# php artisan tinker --execute="dd(config('app.upload_limit'))"
"4096" // vendor/psy/psysh/src/ExecutionClosure.php(40) : eval()'d code:1

@kobaz commented on GitHub (Mar 24, 2025): ``` # php artisan tinker --execute="dd(config('app.upload_limit'))" "4096" // vendor/psy/psysh/src/ExecutionClosure.php(40) : eval()'d code:1 ```
Author
Owner

@kobaz commented on GitHub (Apr 4, 2025):

Strange... isn't it?

@kobaz commented on GitHub (Apr 4, 2025): Strange... isn't it?
Author
Owner

@ssddanbrown commented on GitHub (Apr 5, 2025):

Hi @kobaz,
Sorry, I needed some time to dig further into this.
I've now done some testing with large files.

I created a 4GB random file, then tested uploading, tweaking any config one property at a time to test the resulting behaviour.

Overall, I ended up with a scenario which allows upload/download of these files, and I set the following php.ini values along the way:

upload_max_filesize = 5G
post_max_size = 5G
memory_limit = 512M

During testing, I found that 422 status could be sent if BookStack could not read the upload as a file, which occured when the file exceeded the set upload_max_filesize in my case. A limited post_max_size may result in the same.

My guess is that in your scenario the php.ini values are not being applied as expected.
Often you may have multiple php.ini files on a system, so i've seen a few cases of the wrong one being edited and the changes not applying.

To check the exact php.ini files and options at play, you can create a phpinfo page within the BookStack setup.
Warning: This page can expose private environment info, so ideally only do this in a network-limited-access environment.
You can create this via running the below from your BookStack install:

echo "<?php phpinfo();" > public/info.php

Then go to <INSTANCE_URL>/info or <INSTANCE_URL>/info.php in the browser.
Then search for the php.ini options to see their actual values.
Towards the top of the page, it should tell you which php.ini files are in use.
Remember to delete this info page afterwards by deleting the public/info.php file within your BookStack install folder.

If you are running php via an FPM process (and are editing fpm specific config files) you will need to restart the php-fpm process for changes to take effect.

@ssddanbrown commented on GitHub (Apr 5, 2025): Hi @kobaz, Sorry, I needed some time to dig further into this. I've now done some testing with large files. I created a 4GB random file, then tested uploading, tweaking any config one property at a time to test the resulting behaviour. Overall, I ended up with a scenario which allows upload/download of these files, and I set the following php.ini values along the way: ```ini upload_max_filesize = 5G post_max_size = 5G memory_limit = 512M ``` During testing, I found that 422 status could be sent if BookStack could not read the upload as a file, which occured when the file exceeded the set `upload_max_filesize` in my case. A limited `post_max_size` may result in the same. My guess is that in your scenario the php.ini values are not being applied as expected. Often you may have multiple `php.ini` files on a system, so i've seen a few cases of the wrong one being edited and the changes not applying. To check the exact `php.ini` files and options at play, you can create a phpinfo page within the BookStack setup. **Warning:** This page can expose private environment info, so ideally only do this in a network-limited-access environment. You can create this via running the below from your BookStack install: ```bash echo "<?php phpinfo();" > public/info.php ``` Then go to `<INSTANCE_URL>/info` or `<INSTANCE_URL>/info.php` in the browser. Then search for the `php.ini` options to see their actual values. Towards the top of the page, it should tell you which `php.ini` files are in use. Remember to delete this info page afterwards by deleting the `public/info.php` file within your BookStack install folder. If you are running php via an FPM process (and are editing fpm specific config files) you will need to restart the php-fpm process for changes to take effect.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#5220