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');
Related
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
So I have wordpress plugin that sets my max upload file size and currently it is set to 536mb. (which should be more then enough) But still when I try to upload 3,3 mb .xml file I get an error:
The uploaded file exceeds the upload_max_filesize directive in php.ini.
When trying to Upload
I had the same problem. I tried editing the wp-config.php file and added:
define('WP_MEMORY_LIMIT', '32M');
edited the .htaccess and added:
php_value upload_max_filesize 32M
php_value post_max_size 32M
php_value max_execution_time 300
php_value max_input_time 300
none of the above seemed to work for me. I also tried locating the php.ini file on my directory but couldn't find it.
I created my php.ini file and added:
php_value upload_max_filesize 64M
php_value post_max_size 32M
still nothing changed.
MY SOLUTION
I went back to my cPanel home page and located the MultiPHP INI Editor under the SOFTWARE tab, selected my domain name from the dropdown menu and opened its PHP configuration, scrolled down to the bottom and located the upload_max_filesize directive and changed it from 2MB to the size i want.
That solved my problem. Hope it works for you as well
Open the php.ini file on your hosting server (Typically located somewhere like:
/usr/bin/php5/bin/php.ini in Linux) and adjust the following lines:
; Maximum allowed size for uploaded files.
upload_max_filesize = 536M
; Must be greater than or equal to upload_max_filesize
post_max_size = 536M
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' );
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/
I get similar errors in my error_log in php when users are uploading their files
PHP Warning: POST Content-Length of 11933650 bytes exceeds the limit of 8388608 bytes in Unknown on line 0
In my php.ini (created custom ini file in public_html) would this solve this problem, how much would I have to set it to around 1GB? I am going to change my settings to this in php.ini, will it solve the problem?
upload_max_filesize = 1000M ;1GB
post_max_size = 1000M
What would I set the 'memory_limit' limit to.
Also would this be correct in my script to check file uploaded size is <1GB
if($_FILES["uploadedfile"]["size"]<1000000)
8388608 bytes is 8M, the default limit in PHP. Those changes to php.ini should indeed solve the problem (make sure your restart your Apache server after making them).
Memory limit shouldn't need to be changed here.
I suggest that you should change to post_max_size from 8M to 32M in the php.ini file.
you just setting at php.ini
then set :
upload_max_filesize = 1000M;
post_max_size = 1000M;
then restart your xampp..
Check the image
Try pasting this to .htaccess and it should work.
php_value post_max_size 2000M
php_value upload_max_filesize 2500M
php_value max_execution_time 6000000
php_value max_input_time 6000000
php_value memory_limit 2500M
post_max_size should be slightly bigger than upload_max_filesize, because when uploading using HTTP POST method the text also includes headers with file size and name, etc.
If you want to successfully uppload 1GiB files, you have to set:
upload_max_filesize = 1024M
post_max_size = 1025M
Note, the correct suffix for GB is G, i.e. upload_max_filesize = 1G.
No need to set memory_limit.
In Some cases, you need to increase the maximum execution time.
max_execution_time=30
I made it
max_execution_time=600000
then I was happy.
There might be more than just one php.ini file. For example, when using WAMP there are 2 php.ini files in following directories:
C:\wamp\bin\apache\apache2.4.9\bin
C:\wamp\bin\php\php5.5.12
You need to edit the first one.
I disagree, but the solution to increase the file size in php.ini or .htaccess won't work if the user sends a file larger than allowed by the server application.
I suggest validating this on the front end. For example:
$(document).ready(function() {
$ ('#your_input_file_id').bind('change', function() {
var fileSize = this.files[0].size/1024/1024;
if (fileSize > 2) { // 2M
alert('Your custom message for max file size exceeded');
$('#your_input_file_id').val('');
}
});
});
If you are using Php 5.6.X versions in windows using Wamp, then file location may be in,
C:\Windows\php.ini
Just try with
post_max_size = 100M;
Try to do changes in Apache one. By that your Wamp/XAMP load .ini file
If you are using Laravel and using artisan:serve for running Laravel project you create php.ini in your public directory, then you can specify your configuration.
file_uploads = On
max_execution_time = 300
post_max_size = 20480M
upload_max_filesize = 20480M