Can't increase max upload file size in local WordPress

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

1.create php.ini

in /var/www/html

or modify 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. change .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 this line of codes in a file functions.php

in the theme folder:

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

      

4.Including Download the Max File Size plugin . this plugin changed the message Maximum upload file size: 2 MB.

, but after uploading a file larger than 2MB typed HTTP error.

. (to fix this I also tried every solution I found on the internet (ex: + , + , + ) but nothing changed, and also enabling wordpress log could not help me. nothing happened !! So I gave up. I think the root of this error is a bad fix for this problem)

5. Change the permissions of all files and folders to 777.

6.After every fix I tried, I also restart apache, but nothing changed:

$ sudo service apache2 restart

      

+3


source to share


4 answers


I shouldn't be creating a file php.ini

in /var/www/html/

. I found my way /etc/php/7.0/apache2/php.ini

to phpinfo()

. So I found it and changed the config to this file: upload_max_filesize

, memory_limit

, post_max_size

and max_execution_time

.



NOTE: I was right! HTTP error.

while downloading is a bad solution for this problem. now i can load any media correctly :)

0


source


You can change these lines in the php.ini

current php.



Maximum allowed size for uploaded files.
upload_max_filesize = 256M

      

+3


source


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

      

Search:

file_uploads=...

      

If he writes:

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" must have the largest number of megabytes. Next is "max_file_uploads", followed by "post_max_size" and the last "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>

      

+2


source


you also need to add this filter to your functions.php file to see the allowed loading in your wordpress, its useful not to use a plugin :)

//filter
add_filter('upload_size_limit', 'increase_upload');
function increase_upload($bytes) {
    return 262144000;
}

      

+1


source







All Articles