KB ID 0001125
Problem
When attempting to upload a file to your website, (in my case from within WordPress). You see this error.
Solution
If you are on ‘shared hosting‘ then you may not have access to your php.ini file, if that is the case you should add the following to your .htaccess file, (this will be a hidden file in the root folder of your website).
[box]
######### php_value upload_max_filesize 50M php_value post_max_size 50M php_value max_execution_time 500 php_value max_input_time 500 #########
[/box]
If , (like me), you have your own server, then you will need to edit the php.ini file directly, but where is it? Executing a ‘whereis php.ini‘ command in my case showed me a few copies in various locations, but which one was live?
I’m assuming your website is installed in /var/www/html, so change the commands if yours is in a different location. I’m going to create a .php file in the root of my website, then browse to this file, it will show me all my .php settings, and tell me where the live copy of php.ini is located.
I use nano, if you don’t have it installed, enter the hell that is the ‘vi editor’ and use that instead 🙂
[box]
nano /var/www/html/info.php
[/box]
Then paste in the following text;
[box]
<?php phpinfo(); ?>
[/box]
Then browse to the info.php file on your website with a web browser, i.e. http://www.your-website.com/info.php. You should see something like this.
You can see that the ‘Loaded Configuration File’ is in /etc/php.ini
WARNING: Now it’s a little bit of a security hole having this sat there, so let’s delete this file on the server with the following command;
[box]
rm /var/www/html/info.php THEN Enter 'y' to confirm.
[/box]
How To Edit The php.ini File
Execute the following command;
[box]
nano /etc/php.ini
[/box]
Locate Upload_max_filesize and change its setting accordingly, by default it’s only 2MB.
Also change your post size setting, as the default is only 8MB.
Save and exit the file, then restart Apache.
[box]
/sbin/service httpd restart
[/box]
Try to upload your file again.
Related Articles, References, Credits, or External Links
NA