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:
-
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.inifile: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 thanupload_max_filesize.
For example, to allow uploads of up to 5MB, you would set:
upload_max_filesize = 5M post_max_size = 5MAfter making changes to
php.ini, you will need to restart your web server for the changes to take effect. -
Web Server Configuration: Depending on your web server (Apache, Nginx, etc.), there might be additional configurations that limit the upload size.
- Apache: Check the
LimitRequestBodydirective in your Apache configuration files. - Nginx: Check the
client_max_body_sizedirective in your Nginx configuration.
- Apache: Check the
-
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. -
Form Settings: Ensure that your HTML form has the correct
enctypeattribute set tomultipart/form-datato 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.