Where to add post_max_size in php.ini? - php

I am learning wordpress and i need to edit post_max_size in php.ini. I am using Wamp 3.0.6 64 bit in my local machine. php version is 5.6.25 . I need to change value of post_max_size in php.ini. when i opened that file via wamp control panel, i am not able to find post_max_size(it`s not there in php.ini). I searched everywhere, i am not able to find where i should create this value post_max_size=1024M. so what i need is a section name/line no or something where i can create post_max_size=1024M.

If post_max_size doesn't exists, you can add it everywhere in php.ini file (e.g - on the end of the file)
; Maximum allowed size for uploaded files.
upload_max_filesize = 40M
; Must be greater than or equal to upload_max_filesize
post_max_size = 40M

if you dont want to write code in php.ini file then you can use this code in your wordpress theme functions.php file.
#ini_set( 'upload_max_size' , '64M' );
#ini_set( 'post_max_size', '64M');

Related

Wordpres Error, CentOs server: The uploaded file exceeds the upload_max_filesize directive in php.ini

I've installed the last version of wordpress Centos Server, when tried to install a plugin I got the following error "The uploaded file exceeds the upload_max_filesize directive in php.ini".
I tried to modify php.ini and wp-config-sample.php following some tutorials, but I still can't upload something more than 2 MB. Any advice would be welcome.
you can confirm the status of your php setup using phpinfo(); more details about this can be found here http://php.net/manual/en/function.phpinfo.php
There are three places where you could make the change, where you need to apply the change the value depends on where it is set, also you will need to make sure post_max_size is set the same or higher
.htaccess - https://www.a2hosting.co.uk/kb/developer-corner/php/using-php-directives-in-custom-htaccess-files/setting-the-php-maximum-upload-file-size-in-an-htaccess-file
php.ini - https://www.inmotionhosting.com/support/website/php/increase-the-max-file-upload-size-in-php-ini
you can also try this from within your themes functions.php by using
#ini_set( 'upload_max_size' , '64M' );
#ini_set( 'post_max_size', '64M');
I hope this helps,

Max WP upload limit won't change after editing php.ini

I'm wondering if anyone has any ideas about this - I've been struggling with increasing the max upload size for my wp site for weeks now.
I've tried editing the php.ini parameters 'upload_max_filesize' (umf), 'post_max_filesize' (pmf), 'memory_limit' (ml) to no avail. I need to upload files up to 500M in size and mysteriously managed to get it to upload somewhere around 410M max (even though I had 500M in the .ini file and the wp media panel said 'max file upload size: 500M'). Suddenly today I went to upload and it read 'max file upload size: 0 B' - I checked the .ini and it was set to 2M for 'umf', 0 for 'pmf' (something must have been written over).
I changed umf to 500M, pmf to 500M, ml to 1000M, restarted nginx via command line (the host is digital ocean, os Ubuntu) and the WP media interface still reads 0 B. I checked my info.php file and umf reads 2M there. The loaded config file path is '/etc/php/7.0/fpm/php.ini' and that's the one I'm editing. If anyone had any suggestions before I smash my screen w/ a hammer I would greatly appreciate it :)
Try doing it in your functions.php and see if it makes a change or not.
#ini_set( 'upload_max_size' , '500M' );
#ini_set( 'post_max_size', '500M');
#ini_set( 'max_execution_time', '300' );
If that doesn't work you can also do it in your .htaccess file for WordPress if you're using Apache.
php_value upload_max_filesize 500M
php_value post_max_size 500M
php_value max_execution_time 300
php_value max_input_time 300

WHM Unable to Change Wordpress Max Upload Size

I have several Wordpress installs in a WHM Environment. My WHM PHP(5.6) max upload size is set to 100MB & PHP max POST size 150MB. I also check MultiPHP INI Editor and the max upload size is the same. But for some reason all my Wordpress installs have a max upload size of 8MB. I cannot get it to change.
I've tried the following:
Added php.ini file, but does not help/change
Added php code to the .htaccess, but it causes a Internal Server Error
Added php code to the theme's function.php, but it causes a Internal Sever Error
Spoke with HostGator customer server for a couple hours and they were not able to help.
Any ideas?
Hi Try to add these lines in your theme functions.php
#ini_set( 'upload_max_size' , '64M' );
#ini_set( 'post_max_size', '64M');
Or verify your php.ini files and change these values
upload_max_filesize = 64M
post_max_size = 64M
Or add this in your .htaccess files
php_value upload_max_filesize 64M
php_value post_max_size 64M
You should restart your apache server after changing the php.ini file to take effect on your hosting.
If you are using Wordpress multisites you can have a restriction from Wordpress itself you find it under Settings -> Network settings -> Maximum file size
If you don’t want coding, directly increase max upload size through this free plugin https://ziscom.today/max-upload-size/
After installation go to WordPress menu ‘Max Upload Size’
* Only enter the numeric value in bytes
* 1024 bytes = 1KB
* 1048576 bytes = 1MB
It worked for me. Hope it help for you.

Increasing the upload size in WordPress

I wanted to increase the file upload size limit in wordpress without editing php.ini
So I tried adding .htaccess to the wp-content/uploads directory with rules like these:
php_value upload_max_filesize 10M
php_value post_max_size 20M
php_value memory_limit 32M
This doesn't work in wp-content/uploads, the upload max is still 2MB
This does work if I put this in the websites .htaccess file though.
Why won't this work if I just put the htaccess in the uploads directory? Are there any risks in increasing the upload size for the entire site?
.htaccess won't work unless the PHP script handling the upload exists at wp-content/uploads/ (which it does not). Placing it in that folder does not have the result you may expect because it only impacts scripts located in that folder.
You might try placing .htaccess file into /wp-admin/ which will change upload settings for all files handled inside the admin PHP scripts.
Unclear from your post where else users may be uploading files... are you using upload forms in your public-facing website? If so, you may not want to update the settings server-wide. If not, I see no big risks in making the change.
For increase PHP's file upload limit.
In php.ini file, change the parameter to whatever size you need
(example: )
upload_max_filesize = 32M
...
Simply create blank text file. Save As php.ini
Inside the text file copy-paste the following:
upload_max_filesize = 32M
post_max_size = 32M
============================
Unable to access root directory , than
add this to top of wp-config.php
define('WP_MEMORY_LIMIT', '64M');
To Increase the Maximum file size upload in wordpress
find the php.ini location
#find / -iname php.ini
Get into the folder By default it is 2M we can incerase by setting value to the parameter
#vim php.ini
upload_max_filesize = <Userdefined size> (For eg 20M)
post_max_size = <Userdefined size >
Then if you are using php7.0 restart php7.0-fpm service
#systemctl reload php7.0-fpm.service
If .htaccess not change value and also php.ini not change values, search for .user.ini file in root folder server and search for upload_max_filesize and post_max_size values and replace them.
For increasing PHP's file upload limit.
Go to wordpress root directory and open .htaccess file. In my case it was found in /var/www/html
php_value upload_max_filesize 128M
php_value post_max_size 128M
php_value memory_limit 256M
php_value max_execution_time 300
php_value max_input_time 300
The above code increased my file upload limit to 128 MB in wordpress
2021:
Access /etc/php/8.0/apache2/php.ini
Increase the value of post_max_size. The default value is 8M.
Restart the server with sudo service apache2 restart
Try to add this to functions.php of your theme
#ini_set( 'upload_max_size' , '10M' );
#ini_set( 'post_max_size', '20M');
#ini_set( 'memory_limit', '32M' );

increase max upload limit in wordpress

I need to upload a PDF file to my wordpress site. When I go to Upload New Media, and try uploading it, it says
FileName.pdf exceeds the maximum upload size for this site.
I tried looking for my php.ini file but could not find it. I ran phpinfo() by creating a new file and then opening it in my browser and found this.
Configuration File (php.ini) Path
C:\Windows
Loaded Configuration File
C:\Program Files (x86)\Parallels\Plesk\Additional\PleskPHP5\php.ini
I placed a php.ini files with
upload_max_filesize = 512M
post_max_size = 512M
max_execution_time = 300
in wp-admin, httpdocs and everywhere I had access, nothing worked The max upload file size is just 8 MB. Please help me, My client needs to upload that file.
Note: Please don't tell me to restart server, as I can't, It is a hosted site.
Try with the following plugin:
<?php
/* Plugin Name: Increase Upload Limit */
add_filter( 'upload_size_limit', 'b5f_increase_upload' );
function b5f_increase_upload( $bytes )
{
return 33554432; // 32 megabytes
}
I built this code based on the following core function:
function wp_max_upload_size() {
$u_bytes = wp_convert_hr_to_bytes( ini_get( 'upload_max_filesize' ) );
$p_bytes = wp_convert_hr_to_bytes( ini_get( 'post_max_size' ) );
$bytes = apply_filters( 'upload_size_limit', min( $u_bytes, $p_bytes ), $u_bytes, $p_bytes );
return $bytes;
}
Another option is upload via FTP and use the plugin Add from Server.
What worked for me was editing the php.ini file at
/etc/php5/apache2/php.ini
and adding/editing the following options starting (~ line 786):
memory_limit = 32M
upload_max_filesize = 32M
post_max_size = 32M
I tried different way like attempted to
change my limit directly on my server
through the .htaccess file
wp-config.php
but none of these changes worked for me. Then I came across a post somewhere That I summarised in a blog post(find below)
All you need to do is
create a php.ini
upload to admin directory
Your Php.ini may contain following or whatever limit you need
memory_limit = 32M
upload_max_filesize = 32M
post_max_size = 32M
file_uploads = On
WHM/CPanel users Only
I have been struggling with this for a while now, I found the most simple way to solve this to login to your WHM > PHP Configuration Editor > Change (upload_max_filesize) then hit "SAVE".
This makes a change to your server's php.ini file (the simple way).
Seeing as you're on hosted service, try adding these to your .htaccess file as well:
php_value upload_max_filesize 512M
php_value post_max_size 512M
You won't be able to change these via ini_set();
This applies to cPanel users only. I'm not sure about which versions of cPanel it will work with, but it works with the version 56.0.33.
Login to cPanel > Select PHP version > Switch To PHP Options > Click the greyed out number next to upload_max_filesize > Change > Save
I believe this makes a change to the server's php.ini file.
I'm running WHM / cPanel on a CloudLinux based server. I tried everything. The final solution for me was adding a php.ini file to the /wp-admin/ directory with the following;
memory_limit = 128M
upload_max_filesize = 32M
post_max_size = 32M
Keep in mind I previously tried a php.ini in the document root and the web root directories and those didn't fix the max upload limitation.
You have written php.ini file properly. Just mention path of your php.ini file inside .htaccess file using suPHP_ConfigPath/home/username/public_html. Here replace username with your username mentioned in cpanel. You can refer http://www.vinaypn.com/how-to-fix-maximum-upload-size-exceeded-error-in-wordpress-running-on-shared-hosting/

Categories