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.

Read More

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?

Related posts

Leave a Reply

7 comments

  1. .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.

  2. 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’);

  3. 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
    
  4. 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.

  5. 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

  6. 2021:

    1. Access /etc/php/8.0/apache2/php.ini
    2. Increase the value of post_max_size. The default value is 8M.
    3. Restart the server with sudo service apache2 restart
  7. 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' );