How to change max upload size in php ini

Shared

VPS

Dedicated

You can increase the allowed max upload size by using a PHP directive. By using this directive, you can change the max upload size on one or more directories.

To edit the PHP max upload size, you need to first have a custom .user.ini file. For more information about these files, see this article about .user.ini.

How to Increase PHP Max Upload Size

Once you have chosen whether you are using a .user.ini file, you can continue to the steps below:

  1. Log in to Account Control Center (ACC)
  2. Navigate to your .user.ini file
  3. Enter the max upload size directive into the file like this:
    upload_max_filesize = integer

Replace integer with the new max file size. The integer defaults to using bytes, unless another accepted type of measurement is indicated.

Accepted Measurements:
  • Kilobyte: K
  • Megabyte: M
  • Gigabyte: G

If you use a measurement that differs from default, your max file size directive will look something like these:

upload_max_filesize = 100K

100 kilobytes is now the max upload size.

upload_max_filesize = 50M

50 megabytes is now the max upload size.

upload_max_filesize = 25G

25 gigabytes is now the max upload size.

When finished, save the file. You may not see changes immediately. It may take up to five minutes to go into effect. 

View Discussion

Improve Article

Save Article

  • Read
  • Discuss
  • View Discussion

    Improve Article

    Save Article

    The maximum size of any file that can be uploaded on a website written in PHP is determined by the values of max_size that can be posted or uploaded, mentioned in the php.ini file of the server. In case of hosted server need to contact the administrator of the hosting server but XAMPP has interpreters for the scripts written in PHP and Perl. It helps to create local http server for developers and it provides them full physical and administrative access to the local server. Hence it is the most widely used server and it is very easy to increase the limit on upload files to the desired value in this server.

    The error is generally thrown as follows:

    How to change max upload size in php ini

    Steps to change file upload size: In case of local server

    Note: The upload_max_size limits the size of single attachment and post_max_size is the limit for all the content of the post.

    The upload_max_filesize directive defines the maximum allowed size for file uploads in PHP. As file uploads are done using HTTP POST method, it is also limited by the post_max_size value. It means the actual maximum upload file size for PHP is bound to the lowest value of both post_max_size and upload_max_filesize.

    How to change max upload size in php ini

    post_max_size
    Maximum size of POST data that PHP will accept.
    Its value may be 0 to disable the limit. It is ignored if POST data reading is disabled through enable_post_data_reading.
    http://php.net/post-max-size

    You can increase your PHP application's maximum upload file size by updating both upload_max_filesize and post_max_size directives in your PHP configuration file. You can also configure the same options in the .htaccess file if you don't have administrative access to the system.

    1. Open php.ini file using your preferred text editor.

      $ sudo vi /etc/php/7.4/apache2/php.ini

    2. Search for upload_max_filesize directive.

      ; Maximum allowed size for uploaded files.
      ; http://php.net/upload-max-filesize
      upload_max_filesize = 2M

    3. Set your preferred value for upload_max_filesize.

      upload_max_filesize = 128M

    4. Search for post_max_size directive.

      ; Maximum size of POST data that PHP will accept.
      ; Its value may be 0 to disable the limit. It is ignored if POST data reading
      ; is disabled through enable_post_data_reading.
      ; http://php.net/post-max-size
      post_max_size = 8M

    5. Set your preferred value for post_max_size.

      post_max_size = 128M

      This value should be set at least as high as upload_max_filesize value. Set the value to 0 to impose no limit on the size.

    6. Restart your web server for the changes to take effect

      Alternatively, you can add the following lines in your .htaccess and the setting will apply to scripts from within the .htaccess directory without having to mess with PHP's configuration.

      php_value upload_max_filesize 128M
      php_value post_max_size 128M

    Discuss the article:

    Comment anonymously. Login not required.

    How do I change the upload size in PHP ini?

    To increaes file upload size in PHP, you need to modify the upload_max_filesize and post_max_size variable's in your php. ini file. In addition, you can also set the maximum number of files allowed to be uploaded simultaneously, in a single request, using the max_file_uploads .

    What is the max upload file size in PHP?

    The default PHP values are 2 MB for upload_max_filesize, and 8 MB for post_max_size.

    How do I increase max upload size?

    Open the file in any text editor and add the following code. @ini_set( 'upload_max_size' , '20M' ); @ini_set( 'post_max_size', '13M'); @ini_set( 'memory_limit', '15M' ); Save your changes, and it should increase your file upload size.

    How can I upload more than 2 MB in PHP?

    by default PHP will not handle file uploads larger than 2MB, if one requires PHP to handle larger files then one must set upload_max_filesize and post_max_size in your php. ini file to be larger than 2MB.