Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question

2 Answers 2

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

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

share|improve this answer
    
This did not work. –  Amanda Bynes Oct 28 '12 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 Oct 28 '12 at 20:29

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

share|improve this answer
    
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... –  nekojira Aug 14 '12 at 7:24

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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