0

There are a lot of people discussing how to increase the php max upload file size...

In my case though I want to shrink it from 8MB to 4MB... In my cpanel configuration, if I change the setting, it will eventually change it for all the websites hosted... which is something I don't want (on some other wordpress install I need 8).

I tried placying a php.ini in the user/public_html root where my WP installation is, but no change. If I try placing rules in .htaccess I get an internal server error

is there a way to tell wordpress to set the limit of uploadable files below the php limit? I tried to look if there was such setting in wp-config but haven't found it

thanks

ps - I'm seeking for an advice for single site installations, I'm aware that multisite has the feacture I need... but on single site it's not there

EDIT

I've found this filter which prevents the user to go further if tries to upload an image (any file actually) above a specified size

function custom_file_max_upload_size( $file ) {

    $size = $file['size'];
    if ( $size > 3000 * 1024 ) { 

           $file['error'] = __( 'ERROR: you cannot upload files larger than 3M', 'textdomain' ); 

    }
    return $file;

}
add_filter ( 'wp_handle_upload_prefilter', 'custom_file_max_upload_size', 10, 1 );

after $size you can enter the size in bytes 3000 * 1024 = 3M

this is almost what I want to achieve, except for one thing: the Wordpress Media upload still displays the 8M limit which is the PHP limit. I wish I could get rid of that, otherwise the users of my website may get confused.

2 Answers 2

1

At the top of your wp-config.php file:

ini_set('upload_max_filesize','4M');

2
  • This did not work. Commented Oct 28, 2012 at 15:07
  • For cases where this does not work, then you need to ask your hosting service how you can change the PHP.INI settings properly for their systems.
    – Otto
    Commented Oct 28, 2012 at 20:29
0

If you are running Wordpress multisite then go to wp-admin/network/settings.php and scroll down to upload limit and set this to 3000 or 4000 Kb Per file.

You can also set an upload limit per site eg 20mb

The reason your php.ini or .htacess is not working is that your server probably doesn't allow it. Contact your server administrator to amend your vhost to Allow Override=all

1
  • sorry I forgot to specify that I'm not running a multisite for this specific case; I just have several accounts in my server; also I'd wish to keep my php configuration a bit conservative - anyway if wp multisite allows to set a max upload size I think there must be a way to achieve the same in single site...
    – unfulvio
    Commented Aug 14, 2012 at 7:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.