kengervacio's avatar

Cannot upload files more than 41MB in filament.

Hello!

We're currently having a problem on file uploading in laravel/filament.

What error we're curretly getting is 413 Content Too Large Warning: POST Content-Length of 57237359 bytes exceeds the limit of 41943040 bytes in Unknown on line 0 when trying to upload more than 41MB Files/Images/Videos, anything lower than 41MB works fine.

We've already configure everything in Laravel Forge:

  • PHP.ini's upload_max_filesize = 100M post_max_size = 110M memory_limit = 128M

  • Nginx config and set the client_max_body_size 100M;

Same error, restarted the server, php, nginx, no luck.

FIlament was also set the maxSize to 102400 kb which is to 100MB. FileUpload::make('attachments') ->hiddenLabel(true) ->multiple() ->openable() ->disk('public') ->directory('post-attachments') ->visibility('public') // Max Size: 100mb ->maxSize(102400) ->imageEditor() ->imageEditorAspectRatios([ '16:9', '4:3', '1:1', ])

Returned the same error.

We would like to know what other factors could be blocking our upload to limit the size for file uploads?

Thank you!!

0 likes
3 replies
LaryAI's avatar
Level 58

The error you're encountering, "413 Content Too Large," typically indicates that the server is rejecting the request because the payload is larger than the server is configured to accept. You've already adjusted several settings, but let's ensure everything is covered:

  1. PHP Configuration: You've mentioned setting upload_max_filesize, post_max_size, and memory_limit in php.ini. Make sure these changes are applied to the correct php.ini file. You can verify which php.ini file is being used by running phpinfo() in a PHP script.

  2. Nginx Configuration: You've set client_max_body_size to 100M in your Nginx configuration. Ensure this directive is set in the correct server block and that the configuration file is being loaded. After making changes, restart Nginx with sudo systemctl restart nginx.

  3. Laravel Configuration: Ensure that there are no additional middleware or configurations in Laravel that might be limiting the upload size. Check config/filesystems.php and any custom middleware that might be affecting file uploads.

  4. Filament Configuration: You've set the maxSize in Filament's FileUpload component. This should be fine, but ensure that this setting is correctly applied in your Filament form.

  5. Server Logs: Check the Nginx and PHP-FPM logs for any additional errors or warnings that might provide more context.

  6. Testing: After making these changes, restart both Nginx and PHP-FPM to ensure all configurations are reloaded. You can do this with:

    sudo systemctl restart nginx
    sudo systemctl restart php-fpm
    
  7. Cross-Check: Double-check that there are no other services or proxies (like a load balancer) that might be imposing their own limits on request sizes.

If all configurations are correct and the issue persists, consider testing with a smaller increment in file size to see if there's a specific threshold where the error occurs, which might help in diagnosing the problem further.

kengervacio's avatar

Upon investigation, even though we modified the php.ini file, the app we're still getting 40M for max file size when logging via dd(ini_get('upload_max_filesize'), ini_get('post_max_size'));

What could be the issue in here? is there might be other factors that override my php.ini file?

azimidev's avatar

after updating the php.ini file, make sure you restart both PHP-FPM and Nginx so that the changes take effect:

sudo systemctl restart php-fpm
sudo systemctl restart nginx

Double-check php.ini Limits: Ensure that you’ve modified the right settings in php.ini:

upload_max_filesize = 100M
post_max_size = 110M
memory_limit = 128M
1 like

Please or to participate in this conversation.