Hi guys!

On my Wordpress site I have this message:

File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini or by post_max_size being defined as smaller than upload_max_filesize in php.ini.

On my php.ini file I have the following:

upload_max_filesize: 64M
post_max_size: 90M
memory_limit = 128M

Someone can you help me?

Thanks in advance

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
2 answers

@gianmarcotoscano

There’s a few potential scenarios.

Permissions

If you’ve not already, check the permissions on your files and directories. Unless you’ve changed the user that Apache runs as, files and directories should be owned by the www-data user.

From the CLI, you can run ls -al on your home directory (where index.php is) to see the user and the group that currently owns your files and directories.

If root or another user owns anything there, you’ll most likely need to use chown to change that.

For example, if your home directory is /var/www/html (and ./html is where index.php is), we can run:

chown -R www-data:www-data /var/www/html

That sets all files and directories to be owned by www-data.

Plugins

In some cases, some plugins simply don’t work as expected. If the above doesn’t work, disable all your plugins and try to upload a file. If it succeeds, re-enable plugins one-by-one until you’re not able to upload again. That’ll help identify which plugin is causing the issue.

Check the Logs

tail -20 /var/logs/apache2/error.log

The above command will dump the last 20 lines of the Apache error log to the CLI. If there’s a script error or something else going on during the attempt, it should get logged there and by looking over the errors, you may be able to identify something that isn’t immediately available when disabling and enabling plugins.

Restart Apache

If you made changes to php.ini but didn’t restart Apache, the settings aren’t valid. Only once you restart Apache will those changes take effect.

service apache2 restart

Hello,

You can create a php info file in order to check the current values and check which is the php.ini file in use. In this you can be sure that the values you see in the php.ini file are actually taking effect.

Create the following file in your public_hmtl folder - phpinfo.php and put the following code inside it:

<?php
phpinfo();
?>

You can also use the following command in order to find the location of the php.ini file:

php -i | grep php.ini

The output will be:

Configuration File (php.ini) Path => /etc/php/7.2/cli
Loaded Configuration File => /etc/php/7.2/cli/php.ini

Then check for the current value of uploadmaxfilesize you can also check which is the configuration file - php.ini that is currently used and apply the changes there (if the site using the global php.ini file and you change the values for these settings this will make the changes globally for all sites). Ideally you would like to have the following values:

upload_max_filesize = 64M
post_max_filesize = 64M

You also need to restart your web server in order the changes to take effect.

Hope that this helps!
Regards,
Alex

Submit an Answer