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

davy_yg's avatar
Level 27

Upload limit file pdf

Hello,

I wonder if Laravel have built in upload file limitation?

Like it does not matter you setup the max size file validation, you cannot surpass the built in max file size. Is that true?

Like earlier I setup the validation: 'pdf' => 'file|max:3000',

yet, I still cannot upload file over 2 MB.

ref: https://laravel.com/docs/10.x/validation#rule-max

0 likes
3 replies
LaryAI's avatar
Level 58

In Laravel, while you can set validation rules to limit the file size, such as 'pdf' => 'file|max:3000', there are other factors that can affect the maximum file upload size. Here are a few things to check:

  1. PHP Configuration: The PHP configuration on your server has settings that control the maximum file upload size. You need to check and possibly adjust the following settings in your php.ini file:

    • upload_max_filesize: This setting controls the maximum size of an uploaded file.
    • post_max_size: This setting controls the maximum size of POST data that PHP will accept. It should be larger than upload_max_filesize.

    For example, to allow uploads of up to 5MB, you would set:

    upload_max_filesize = 5M
    post_max_size = 5M
    

    After making changes to php.ini, you will need to restart your web server for the changes to take effect.

  2. Web Server Configuration: Depending on your web server (Apache, Nginx, etc.), there might be additional configurations that limit the upload size.

    • Apache: Check the LimitRequestBody directive in your Apache configuration files.
    • Nginx: Check the client_max_body_size directive in your Nginx configuration.
  3. Laravel Configuration: Ensure that your Laravel application is correctly set up to handle file uploads. The validation rule 'pdf' => 'file|max:3000' specifies a maximum file size of 3000 kilobytes (approximately 3MB). If you want to allow larger files, adjust this value accordingly.

  4. Form Settings: Ensure that your HTML form has the correct enctype attribute set to multipart/form-data to handle file uploads properly.

By checking and adjusting these settings, you should be able to upload files larger than 2MB. If you continue to experience issues, double-check each configuration to ensure they are set correctly.

Tray2's avatar

Laravel has no limit, it's php that has a limit, it is by default set to 2MB, you can change that in php.ini.

There are two parameters for it, one is the file size, and the other it the post size.

EveAT's avatar

Look at the output of phpinfo(), for exemple in you controller:

 return phpinfo();

Check for upload_max_filesize and post_max_size. By default PHP sets them to 2M. You can increse them in your php.ini file.

You'll find the path of the correct php.ini file in Loaded Configuration File line - one of the top in the phpinfo() output and make the changes there. Restart php and check if the values in phpinfo() output changed.

Please or to participate in this conversation.