How to Solve Error Message The uploaded file exceeds the upload_max_filesize directive in php.ini

Posted on


This is an article where the main focus is discussing about a certain error. The error message is ‘The uploaded file exceeds the upload_max_filesize directive in php.ini’. That error message is available as part of the title of this article. It is an error message occurred upon uploading a compressed file with the ‘.zip’ file extension in the WordPress-based administration page. The following is the image showing the error message :

Check for php file version :

The error appear because the uploaded file in the compressed format of ‘.zip’ is too large. So, wordpress complaints and give an error message as in the above page. There is a solution to solve the above problem. The solution is quite simple and it is already expressed in detail. Since the size or the value of the ‘upload_max_filesize’ directive is to small in the php.ini file, just change it accordingly. Increase the value of the ‘upload_max_filesize’ directive in the php.ini file. Before further action for editing the php.ini file, firstĀ  of all, check the running version of the php. There are several ways to find out which one is the running php in the system by executing the following command :

root@hostname ~# php --version
PHP 7.2.19-0ubuntu0.18.04.2 (cli) (built: Aug 12 2019 19:34:28) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.19-0ubuntu0.18.04.2, Copyright (c) 1999-2018, by Zend Technologies
root@soulreaper ls -al /usr/bin/ | grep php
-rwxr-xr-x  1 root root        2668 Feb 13  2018 jsonlint-php
lrwxrwxrwx  1 root root          21 Mar 28  2019 php -> /etc/alternatives/php
-rwxr-xr-x  1 root root     4899864 Aug 13 02:34 php7.2
root@hostname ~# update-alternatives --list php
root@hostname ~# update-alternatives --config
update-alternatives: --config needs 

Use 'update-alternatives --help' for program usage information.
root@hostname ~# update-alternatives --config php
There is only one alternative in link group php (providing /usr/bin/php): /usr/bin/php7.2
Nothing to configure.
root@hostname ~# update-alternatives --display php
php - auto mode
  link best version is /usr/bin/php7.2
  link currently points to /usr/bin/php7.2
  link php is /usr/bin/php
  slave php.1.gz is /usr/share/man/man1/php.1.gz
/usr/bin/php7.2 - priority 72
  slave php.1.gz: /usr/share/man/man1/php7.2.1.gz
root@hostname ~# 

Solving the problem

The previous part is just informing the background of the problem. After knowing that there is an available and running php installed in the system, just edit the php file configuration to change the value of the directive. Usually, the php file configuration exist in /etc/php.ini. Just open and edit the content of the file. The following is the actual part of the content and value of the ‘upload_max_filesize’ directive :

; Maximum allowed size for uploaded files.
upload_max_filesize = 2M

By default, the actual size of the file is only 2M. Since the size of the uploaded file is larger than the default value in the upload_max_filesize, just change it. Suit the value with the size of the intended file for upload. For an example, in this context, change the value to ‘200M’. So, the content will change as follows :

; Maximum allowed size for uploaded files.
; upload_max_filesize = 2M
upload_max_filesize = 200M

In the above file, the directive with the smaller value is commented. On the other hand, the directive with the larger value which is a new file is added after.

Since there is a change in the php file configuration, there must an action to restart the Apache Webserver or any Webserver used. It is a must in order to implement the actual change in the php file configuration. Just execute the command for restarting the service in the command line interface as follows :

root@hostname ~# systemctl restart apache2
root@hostname ~# 

Finally, after restarting the service try to upload the file once more.

Leave a Reply