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

TheKoswog's avatar

Can't upload over 10mb file Laravel

How can I upload a file over 10 mb in my Laravel script, all upload size settings on my server are over 100 mb, but I cannot upload over 10 mb.

I would be glad if you help.

0 likes
14 replies
jlrdw's avatar

What errors are you getting.

Edit:

Also what is the network tab showing.

click's avatar

Upload limits can be set in many places, can you be more specific on what kind of error you get?

  1. Via front end (javascript)
  2. Via a Laravel validation rule, you will get a HTTP 422 response
  3. PHP limits it via upload_max_filesize and post_max_size, verify if you set it correctly by dumping the values: dd(ini_get('upload_max_filesize'), ini_get('post_max_size'))
  4. Nginx also has a setting, client_max_body_size: https://linuxhint.com/what-is-client-max-body-size-nginx/
  5. If you have some kind of managed/shared hosting check with your hosting provider if you can change it in their settings.

And of course, after making changes to php and/or nginx restart the services so your changes take effect.

martinbean's avatar

@thekoswog You can’t upload files that are larger than a few megabytes in size in one go, because you’ll either hit a memory limit or a timeout limit, no matter what you change your php.ini or server settings to be. There’s just no way to let a browser way an infinite amount of time, or read a file into more RAM that’s available.

Instead, you’ll need to upload the file into “chunks” from the browser, and then assemble the file server-side once all chunks have been sent. This is what services like S3 will do when uploading files that are multiple megabytes or even gigabytes in size.

PovilasKorop's avatar

10mb is the default limitation in Spatie Media library package. Could it be related to that config/medialibrary.php?

return [
    /*
     * The maximum file size of an item in bytes.
     * Adding a larger file will result in an exception.
     */
    'max_file_size' => 1024 * 1024 * 10,
8 likes
PovilasKorop's avatar

@jlrdw I don't think it's mentioned specifically somewhere in their docs. I just remember painfully bumping into that number myself, a long time ago :)

GuyVerville's avatar

@PovilasKorop The MediaLiabry Pro Livewire component seems not to read this config. I get the same error after changing to a higher amount.

majiduppsala's avatar

@PovilasKorop Thank you Povilas. Was banging my head for a couple of hours, the debug mode is ON, maxfileupload is up, client body size is configured, Nginx conf is also configured for file size and still there was error, Your hint fixed it.

TheKoswog's avatar
TheKoswog
OP
Best Answer
Level 1

Status code gives 500 Error, it does not load, I think I do not know where to find the solution for this error is related to the script, but I need to be able to install it, I do not understand what to do, thank you very much for writing immediately to help

A helpful site, you are very good, thank you, I will write when the problem is solved, thank you again.

TheKoswog's avatar

I'm getting the same error again

[2023-01-06 18:18:46] production.ERROR: File /tmp/phpEvFv4w has a size of 44.35 MB which is greater than the maximum allowed 10 MB {"userId":7,"exception":"[object] (Spatie\MediaLibrary\MediaCollections\Exceptions\FileIsTooBig(code: 0): File /tmp/phpEvFv4w has a size of 44.35 MB which is greater than the maximum allowed 10 MB at /var/www/vhosts/vawog.com/api.vawog.com/vendor/spatie/laravel-medialibrary/src/MediaCollections/Exceptions/FileIsTooBig.php:15)

thomas_rm's avatar

Hi,

I ran into the same error, and turns out it's the Livewire's config for temporary_file_upload that was limited to 12288KB. If someone is having the same issue, using Livewire (V3 in my case), this might be useful:

  1. Publish the livewire config file:

    php artisan livewire:publish --config
    
  2. Update the temporary_file_upload rules - set the max value:

        'temporary_file_upload' => [
            'disk' => null,        // Example: 'local', 's3'              | Default: 'default'
            'rules' => ['max:64000'],       // HERE!
            'directory' => null,   // Example: 'tmp'                      | Default: 'livewire-tmp'
            'middleware' => null,  // Example: 'throttle:5,1'             | Default: 'throttle:60,1'
            'preview_mimes' => [   // Supported file types for temporary pre-signed file URLs...
                'png', 'gif', 'bmp', 'svg', 'wav', 'mp4',
                'mov', 'avi', 'wmv', 'mp3', 'm4a',
                'jpg', 'jpeg', 'mpga', 'webp', 'wma',
            ],
            'max_upload_time' => 5, // Max duration (in minutes) before an upload is invalidated...
        ],
    
  3. Clear your config cache and you're done!

3 likes
sctmp's avatar

@thomas_rm Thanks! I am using Filament and Spatie Media Library. I had configured both of these to use a higher limit, but I was still getting an error due to the Livewire default limit.

Please or to participate in this conversation.