Increasing the upload volume through the file function - php

I want to increase the upload size of WordPress through function file.
I used the following code before and it didn't work:
#ini_set( 'upload_max_size' , '512M' );
#ini_set( 'post_max_size', '512M');
#ini_set( 'max_execution_time', '300' );
But when I put this code in the .htaccess file, the upload volume increases:
php_value upload_max_filesize 512M
php_value post_max_size 512M
php_value max_execution_time 300
php_value max_input_time 300
Is there a code that can be inserted into the function file to connect to the .htaccess file and increase the upload size of WordPress?
For example something like this code:
function management(){
// The code to increase the upload volume
}
add_action('htaccess','management');

Related

The uploaded file exceeds the upload_max_filesize directive in php.ini. Unable to upload a new theme in wordpress

I am unable to upload a new theme in wordpress.The maximum limit showing right now is 10 mb. What changes should I make in CPanel. I have created a new file in Public_html named php.ini.
and pasted these lines.
upload_max_filesize = 256MB
post_max_size = 32M
memory_limit = 32M
max_execution_time = 300
1: Theme Functions File
There are cases where we have seen that just by adding the following code in theme’s functions.php file, you can increase the upload size:
#ini_set( 'upload_max_size' , '64M' );
#ini_set( 'post_max_size', '64M');
#ini_set( 'max_execution_time', '300' );
2. Create or Edit an existing PHP.INI file
For this method you will need to access your WordPress site’s root folder by using FTP or File Manager app in your hosting account’s cPanel dashboard.
In most cases if you are on a shared host, then you will not see a php.ini file in your directory. If you do not see one, then create a file called php.ini and upload it in the root folder. In that file add the following code:
upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 300
This method is reported to work for many users. Remember if 64 doesn’t work, then try 10MB (sometimes that work).
3. htaccess Method
Some people have tried using the .htaccess method where by modifying the .htaccess file in the root directory, you can increase the maximum upload size in WordPress. Edit the .htaccess file in your WordPress site’s root folder and add the following code:
php_value upload_max_filesize 64M
php_value post_max_size 64M
php_value max_execution_time 300
php_value max_input_time 300
Using .htaccess file in wordpress. You can define below lines,
Open it .htaccess in folder and added the following into a newline at the end of the file.
php_value memory_limit 256
php_value upload_max_filesize 64M
php_value post_max_size 64M
php_value max_execution_time 300
php_value max_input_time 1000
Save your changes and overwrite the .htaccess file.
Get More info, you can follow the link,
For upload file size: https://www.bitcatcha.com/blog/increase-maximum-upload-file-size-in-wordpress/
For Increase Memory Limit size :https://premium.wpmudev.org/blog/increase-memory-limit/
you can create php.ini file in wp_admin folder in root wordpress directory
open php.ini and override these values
1- upload max size
2- post max size
3- max execution time
now php.ini file looks like that
upload_max_filesize = 128M
post_max_size = 128M
max_execution_time = 180

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

Not able to upload csv bigger than 8MB file

I have created a custom module in magento and it has an option of import csv file.
it uploads file upto 8MB but when i try to upload bigger than 8MB file, it uploads the file in directory but doesn't make any entry in database.
I have set those configuration in php.ini but still no luck.
php_value upload_max_filesize 20M
php_value post_max_size 24M
php_value max_input_time 300
php_value max_execution_time 3000
Please help

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 file size WordPress multisite

I'm trying to increase the max file size for a WordPress multisite install (currently 1MB). I've tried a number of things to no avail. The things I've tried:
Adding these to my hosts php.ini file:
memory_limit = 300M
post_max_size = 32M
upload_max_filesize = 32M
Adding these to the functions.php file in the theme:
#ini_set('upload_max_size' , '32M');
#ini_set('post_max_size', '32M');
#ini_set('max_execution_time', '300');
Adding these to the .htaccess file:
php_value upload_max_filesize 32M
php_value post_max_size 32M
I even tried checking the wp-includes/default-constants.php.
Interestingly, I have another WordPress install (not multisite) on the same server that seems to work perfectly (max upload there is 32MB). Any ideas what to try next?
Thank you.
Figured it out. In all my infinite wisdom, I completely missed the "Max upload file size" setting in Network Admin > Settings > Network Settings. It's right near the bottom of the page.
#Allpnay posted the solution, just paste on functions.php:
add_filter( 'upload_size_limit', 'PBP_increase_upload' );
function PBP_increase_upload( $bytes )
{
return 1048576; // 1 megabyte
}
In my case want 8mb so change for
return 8000000; // 8 megabyte
Phil is correct: Network Admin (My Sites > Network Admin) then go to Settings > Network Settings. It's near the bottom under Upload Settings, called Max upload file size.
However, also note you have to go with a flat 1000kb or 2000kb etc.
I put 1500kb in there and it still limited me to 1 MB but when I increased it to 2000kb it allowed up to 2 MB
Try this, i use this filter for my Multisite and this work great
add_filter( 'upload_size_limit', 'PBP_increase_upload' );
function PBP_increase_upload( $bytes )
{
return 1048576; // 1 megabyte
}
Create a file called .user.ini in your Wordpress root folder and add the following to it:
upload_max_filesize = 64M
post_max_size = 64M
memory_limit = 64M
max_execution_time = 300
This fixed it for me after all else failed.
Try creating a php.ini file with
memory_limit = 32M
upload_max_filesize = 32M
post_max_size = 32M
file_uploads = On
and save it in the wp-admin/ folder :)
If this doesn't work, try adding the following to wp-config.php
define('WP_MEMORY_LIMIT', '64M');
ini_set('post_max_size', '32M');
ini_set('upload_max_filesize', '32M');

Categories