Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot increase maximum upload file size in local WordPress

I am using my own localhost (ubuntu and apache2) for running wordpress 4.8 . I want to increase maximum upload file size. I tried these ways but didn't solve :

1.creating php.ini in /var/www/html or changing it in /etc/php/7.0/apache2/php.ini:

upload_max_filesize = 512M
memory_limit = 512M
post_max_size = 512M
max_execution_time = 300

2.changing .htaccess in /var/www/html:

php_value upload_max_filesize 512M
php_value post_max_size 512M
php_value max_execution_time 300
php_value max_input_time 300

3.adding these line of codes in functions.php file in the theme folder:

@ini_set('upload_max_size' , '512M');
@ini_set('post_max_size', '512M');
@ini_set('max_execution_time', '300');

4.using Upload Max File Size plugin. this plugin changed Maximum upload file size: 2 MB. message but after uploading file more than 2mb the HTTP error. accrued. (for fixing this i also tried every solution i found on web (ex: +,+,+) but nothing changed. also turning on wordpress log cant help me. there wasn't anything!! So i gave up. i think the root of this error is bad fix for this problem)

5.changing permissions of all files and folder to 777.

6.after every fix i tried, i also restart apache but nothing changed:

$ sudo service apache2 restart
like image 855
erfan mehraban Avatar asked Jul 18 '17 08:07

erfan mehraban


People also ask

How do I increase the max upload size in WordPress with plugins?

The usual, automatic way; Open WordPress admin, go to Plugins, click Add New. Enter “increase maximum upload” in search and hit Enter. Plugin will show up as the first on the list, click “Install Now”

What is the maximum upload size for WordPress?

Your WordPress hosting provider will set a default maximum file upload size when you sign up and install WordPress. Your hosting provider defines this limit, and it usually ranges from 2MB to 500MB. For most WordPress website owners, this limit will be more than enough.


4 Answers

Go to C:/Xampp/php/php.ini and find:

memory_limit=.....M

Change it to:

memory_limit=10000M

Then scroll down to:

post_max_size=.....M

And change it to:

post_max_size=9999M

Find:

file_uploads=...

If it's of write:

file_uploads=On

Scroll down and find

upload_max_filesize=....M

Write there:

upload_max_filesize=9000M

Also find:

max_file_uploads=.....

And write there:

max_file_uploads=10000M

Attention! Be careful! "Memory_limit" should have the largest number of megabytes. The next is "max_file_uploads", after which is "post_max_size", and last the "upload_max_filesize".

If there is still the same error, make your .htaccess like this:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /your_site_name/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /your_site_name/index.php [L]
</IfModule>

# END WordPress
    # WP Maximum Execution Time Exceeded
    <IfModule mod_php7.c>
    php_value max_execution_time 300

    php_value upload_max_filesize 9000M
    php_value post_max_size 9999M
    php_value max_input_time 300

    </IfModule>
like image 178
Atanas Avatar answered Oct 19 '22 00:10

Atanas


You can change these lines on your php.ini file of currently running php version.

Maximum allowed size for uploaded files.
upload_max_filesize = 256M
like image 38
Samad Avatar answered Oct 18 '22 22:10

Samad


I shouldn't create any php.ini file in /var/www/html/. I found /etc/php/7.0/apache2/php.ini path in phpinfo() details. So i found and changed these configs in this file : upload_max_filesize, memory_limit, post_max_size and max_execution_time.

NOTE: I was right! HTTP error. while uploading media was because of bad fix for this problem. now i can upload any media correctly :)

like image 2
erfan mehraban Avatar answered Oct 18 '22 23:10

erfan mehraban


you need also to add this filter to the functions.php file to see the allowed upload in your Wordpress , its good to not use plugin :)

//filter
add_filter('upload_size_limit', 'increase_upload');
function increase_upload($bytes) {
    return 262144000;
}
like image 1
Fadi Nouh Avatar answered Oct 19 '22 00:10

Fadi Nouh