How To Enable “Allow Url Fopen” Or Change “The Maximum Filesize” On WordPress?

The php.ini file is where you declare changes to your PHP settings on your server. You can edit the existing php.ini, or create a new text file in any subdirectory (wp-admin folder is recommended) and name it php.ini.


“I want to enable allow_url_fopen or change the max_filesize or max_execution_time on my wordpress site. Where and how to do these things on cPanel?”

We see these questions frequently on internet forums! everywhere we look lacks the real answer. 

How to enable “allow_url_fopen” on WordPress:

Sometimes you need to setup “allow_url_fopen = On” to install a demo theme or other plugins.

You can do it via your php.ini file by adding the following line:

allow_url_fopen = On

What is php.ini file? And how to find it on WordPress:

“How can I find my php.ini file on wordpress?” ― This is another general query popped up from the beginners’ profiles we see everywhere.

The php.ini file is where you declare changes to your PHP settings on your web hosting server. You can edit the existing php.ini, or create a new text file in any subdirectory (we recommend to do it in wp-admin folder) and name it php.ini.

How to change Maximum File Size or Maximum Execution Time on WordPress:

To check your maximum file size limit, you can simply go to Post/Page Editor » Media » Add New page and you will see the maximum file uplaod size limit for your WordPress site.

You can configure these settings through various ways:

1| Through Theme Functions File:

There are cases where we have seen that just by adding the following code in theme’s functions.php file, you can increase the upload size:

@ini_set( 'upload_max_size' , '64M' );

@ini_set( 'post_max_size', '64M');

@ini_set( 'max_execution_time', '300' );

2| Through php.ini File:

The php.ini should be in the wp-admin directory, if it isn’t just create it and then define what’s your needs to maximize upload_filesize or execution_time, by default it should contain:

upload_max_filesize = 64M;
post_max_size = 64M;
max_execution_time = 300;


3| Through .htaccess File:

Open cPanel » online file manager » htdocs » .htaccess file in a code editor (in desktop version) and then add text:

php_value upload_max_filesize 1000M

php_value post_max_size 2000M

php_value memory_limit 3000M

php_value max_execution_time 1800

php_value max_input_time 180

php_value allow_url_fopen On (if needed)

You can disable one of these command-lines any time just by putting a ‘#’ at the beginning of the line.

PHP Settings WordPress Plugin:

Since you are hosting your website with WordPress CMS, the simplest procedure to configure all these complicated settings is by installing plugins. The plugin mentioned below will indeed help you:

https://wordpress.org/plugins/custom-php-settings/

It provides a simple user interface with a code editor to edit your local .ini settings.

You can use this plugin to change settings like upload_max_filesize or max_execution_time which are often set to very low values by the hosting companies.

Leave a Reply