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 atwp-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.
…
Simply create blank text file. Save As php.ini
Inside the text file copy-paste the following:
============================
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
Get into the folder By default it is 2M we can incerase by setting value to the parameter
Then if you are using php7.0 restart 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
The above code increased my file upload limit to 128 MB in wordpress
2021:
/etc/php/8.0/apache2/php.ini
post_max_size
. The default value is8M
.sudo service apache2 restart
Try to add this to
functions.php
of your theme