How to decrease the file size upload limit?

How do I decrease my media file size upload limit from 20 MB to 500 KB? I actually tried to follow the solution used in Decrease file size upload in Media but got a “undefined add_filter()” error. I inserted the code at the bottom of functions.php.

Using WP 3.5.1

Read More

What should I do? Thank you

Related posts

5 comments

  1. The answer to this questions depends on the level of access you have to your server. Shared hosts often limit the options you have. Your options are:

    1) Changing a directive in your php.ini: Heres how to find it.

    This will change the setting for all websites using php on this server. Many shared hosts don’t allow this.

    Find the line in that says upload_max_filesize and edit it to look like the following:

    upload_max_filesize = 500K

    2.a) Setting an ini directive in the .htaccess file (if you use apache):

    In the .htaccess file in the WordPress root directory (where the wp-config.php file is) add the following on a new line:

    php_value upload_max_filesize 500K

    This will change the setting for that installation of WordPress only.

    Be aware, many shared hosts will not allow this. Additionally this will only work if you are using PHP as an apache module and AllowOverride is set to “Options” or “All” more info here.

    2.b) With a .user.ini file:

    Much like .htaccess above, a .user.ini file is used to override directives at a directory level. This will only work if your server is using the CGI/FastCGI SAPI. So if you’re on Azure App Service/IIS or something similar this is probably what you want.

    Syntax is: upload_max_filesize = 500K

    3) Changing the directive in WordPress with ini_set():

    This should work on a shared host.

    Add the following line to your functions.php:

    ini_set( 'upload_max_size' , '500K' );

    This works by changing the setting every time this file is run. functions.php is run on every load when the theme is active so this effectively changes the limit when using your theme.

    Bonus: WordPress Multisite

    Navigate to Network Admin > Settings > Network Settings. You should see the setting close to the bottom of the page. However, the maximum limit you can set here is dictated by the other PHP settings outlined in the this answer.

  2. You can use this code inside of the functions.php file to in case or decrease the upload size. You can also increase the size by changing 2M to more.

    @ini_set('upload_max_size', '500K');
    @ini_set('post_max_size', '500K');
    @ini_set('max_execution_time', '300');
    
  3. I am using the plugin WP Image Size Limit. It works about 80% the way I like.

    A couple of things I don’t like:

    1. In the Upload Media view still says 20 MB is the limit.
    2. Looks like it does the size check AFTER the upload is done, instead of before. Seems inefficient to me.
  4. First Method

    You can add this in your functions.php file :

    @ini_set( 'upload_max_size' , '500K' );
    @ini_set( 'post_max_size', '500K');
    @ini_set( 'max_execution_time', '100' );
    

    Second Method

    Add this in your .htaccess file :

    php_value upload_max_filesize 500K
    php_value post_max_size 500K
    php_value max_execution_time 100
    php_value max_input_time 100
    

    Thirs Method

    Add this in your php.ini file :

    upload_max_filesize = 500K
    post_max_size = 500K
    max_execution_time = 100
    
  5. put this into your .htaccess file

    php_value upload_max_filesize 500K
    php_value post_max_size 500K
    php_value max_execution_time 100
    php_value max_input_time 100
    

Comments are closed.