Media library issues when uploading multiple files

After migrating to a new server and running on version 4.1.9 I’m having major issues uploading multiple files at once in the media manager.

I select 4-5 files, start upload and the progress bar very quickly runs to 100% but way before reaching “the end of the line” at the far right of the window. No files appear in the file manager. Only after refresing with the button (not the browser refresh, the toolbar button in media manager) do consistenly 2 of the files appear in the media manager, the rest are no were to be found.

Navigating away from the media manager to say settings or another backend page i get a message saying “Upload was cancelled”.

This did not happen on earlier versions, and I’m wondering if its tied to the new Ajax changes introduced in 4.1? Is this a bug or is my server misconfigured?

Running on Laravel forge VPS latest version (php8.4) with defaults except PHP max file size set to 50mb and execution time set to 300secs.



I guess it worth checking this quickly:

1. Nginx client_max_body_size

Laravel Forge uses Nginx, and its default client_max_body_size is only 1MB. Even though you set PHP’s max file size to 50MB, Nginx will silently reject requests that exceed its own limit. When uploading multiple files, the combined POST body exceeds 1MB quickly.

SSH into your server and check:

Check current Nginx config for your site

cat /etc/nginx/sites-enabled/your-site.conf | grep client_max_body_size

In Forge, go to Sites > your site > Nginx Configuration and add/update inside the server block:

client_max_body_size 50M;

Then restart Nginx:

sudo systemctl restart nginx

2. PHP post_max_size

This must be larger than upload_max_filesize. When uploading multiple files, the total POST size is the sum of all files. If you set upload_max_filesize = 50M but post_max_size is still at the default 8M, multi-file uploads will fail.

Check and fix in your php.ini or via Forge’s PHP settings:

upload_max_filesize = 50M
post_max_size = 256M

post_max_size should be significantly larger than upload_max_filesize to accommodate multiple files plus form overhead.

3. PHP max_file_uploads

This defaults to 20, which should be fine for 4-5 files, but verify it hasn’t been set lower:

php -i | grep max_file_uploads

4. Verify all settings are active

PHP-FPM sometimes uses a different php.ini than CLI. Check the actual runtime values:

php-fpm8.4 -i | grep -E “post_max_size|upload_max_filesize|max_file_uploads”

Or create a temporary phpinfo() file to confirm the web-facing values match what you expect.

After making changes, restart PHP-FPM:

sudo systemctl restart php8.4-fpm

Why only 2 files appear

Nginx likely accepts the first chunk of the multipart POST (containing 1-2 files worth of data) before hitting the size limit and terminating the connection. The files that fit within the limit get processed; the rest are dropped. The progress bar behavior is the JavaScript client reporting based on bytes sent to the socket, not bytes actually accepted by the server.

Thank you for such detailed and great input. I’ve checked most of this leading up to posting here, but I’ve gone over again to make sure.

  1. nginx is set to these variables, and have been reloaded severeal times
    client_max_body_size 100M;
    client_body_buffer_size 512k;
    client_body_timeout 300s;
    fastcgi_read_timeout 300s;

  2. post_max_size have been set both to 0 and to 512M which is is at currently. phpinfo() reports this value as well. Upload_max_size reports at 50M.

  3. max_file_uploads set to 20, but fails as it is now even with 3-5 files.

  4. phpinfo() reports all these variables correctly and php have been reloaded.

To be sure I’ve rebooted the server, cleared all cache in October time and time again, and also made sure to hard refresh browsers. This occurs across all browsers and both on Mac and Windows, so it’s definitely server related, I just cannot understand why?

As you write Nginx likely accepts the first chunk of the multipart post, if that was set too low, wouldnt the files fail to upload. During testing I see that the two files that are indeed uploaded are complete and working no matter the size of the file as long as its under the set max file size. I just uploaded a couple of files of 12-13 mb each, does this not indicate that the nginx client_max_body_size is working?

I’m stumped…

Again, thank you for your input :slight_smile: