Signup/Sign In

How to Increase Max File Upload Size in Wordpress

Posted in Programming   LAST UPDATED: NOVEMBER 16, 2018

    Have you ever encountered the following error "exceeds the maximum upload size for this site" when you try to upload a file to your Wordpress website? Here is the solution for it. The default file upload limit for Wordpress is set as per your server limit. But you can increase the maximum size in PHP configuration file, as WordPress uses PHP (which is already installed on your server ) or you can increase the same using the .htaccess server file.


    Method 1: Using PHP

    Let's start with the first method:


    1) Check your current upload limit

    • Go to media option in the left panel in the Wordpress dashboard.
    • Click on "Add New" option. Here you can see the maximum upload limit.


    2) Find PHP version installed on your server

    Use the below code to find the version of PHP installed on your server:

    php -version


    3) Find the path of PHP file

    Next, we need to locate where PHP is installed, i.e. PHP installation directory.

    • Go to the working directory on your server
    • Create a file with name info.php
    • Insert the below code to view the properties of PHP
    <?php
        // prints PHP version and other details
        phpinfo();
    ?>

    Open the file in the Web browser and you will see the webpage as below:


    4) Copy the path present at Loaded Configuration File

    In the sixth row on the left, you will see "Loaded Configuration File" text, copy the path in the right column against it.


    5) Edit PHP.INI file

    • Use Nano Editor to edit the file
    
    nano /etc/php/7.1/apache2/php.ini
    • Search for the term "UPLOAD"

    use CTRL + W (to search)

    • Uncomment the line upload_max_filesize = <limit size> (Set the value for maximum file size that you want to upload)
    • Save the file (CTRL + X)
    • Restart apache
    serive apache2 restart


    6) Confirm the max upload size

    • Go to media option in the left panel in the Wordpress dashboard
    • Click on Add New option. Here you can see the maximum upload limit.




    Method 2: Change the Max Upload size using .htaccess

    • Go to the working directory on your server.
    • Create a file with name .htaccess
    • Copy the below code with your requirements
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    php_value upload_max_filesize 64M
    php_value post_max_size 64M
    php_value max_execution_time 300
    php_value max_input_time 300
    </IfModule>
    # END WordPress

    Save the file and restart your apache server.

    service apache2 restart



    Method 3: Use Increase Upload Max Filesize plugin

    • Go to plugins.
    • Click on Add New.
    • Search for the term "Increase Upload Max Filesize"
    • Install it

    • After the Plugin is activated. Navigate to its settings and enter the desired value for your new upload size.

    About the author:
    I am a Devops Engineer and Penetration Tester. I love to share about Devops and Hacking.
    Tags:WordpressFile Upload SizeHow To
    IF YOU LIKE IT, THEN SHARE IT
     

    RELATED POSTS