292

I am getting this error when trying to upload an import on WordPress on my XAMPP local dev environment:

Warning: POST Content-Length of 8978294 bytes exceeds the limit of 8388608 bytes in Unknown on line 0

I changed the upload_max_filesize from 2M to 1000M, but that didn't seem to do anything.

Any ideas?

novicePrgrmr
  • 18,647
  • 31
  • 81
  • 103
  • 23
    Try increasing post_max_size to 20M – Dr. Dan Jul 30 '12 at 10:19
  • If you are considering just a WP upload - just increase the post_max_size(all the current uploads together) and possibly upload_max_filesize(for single file)... however if you want to hide the error if someone would try to upload too large files (over your limits) see http://stackoverflow.com/questions/21704930/how-to-prevent-warning-post-content-length-and-memory-size – jave.web Feb 12 '14 at 15:07
  • 5
    a note to passersby: this error and fix is not specific to WordPress or XAMPP. It is applicable generally to the PHP error `POST Content-Length of X bytes exceeds the limit of Y` – code_monk Nov 09 '14 at 17:43
  • Possible duplicate of [POST Content-Length exceeds the limit](https://stackoverflow.com/questions/6279897/post-content-length-exceeds-the-limit) – Shashanth May 11 '18 at 05:00
  • Make sure you're updating the correct php.ini: https://stackoverflow.com/a/58999601/470749 – Ryan Nov 22 '19 at 18:09

25 Answers25

441

8388608 bytes is 8M, the default limit in PHP. Update your post_max_size in php.ini to a larger value.

upload_max_filesize sets the max file size that a user can upload while post_max_size sets the maximum amount of data that can be sent via a POST in a form.

So you can set upload_max_filesize to 1 meg, which will mean that the biggest single file a user can upload is 1 megabyte, but they could upload 5 of them at once if the post_max_size was set to 5.

Changes will take effect after a restart of the server.

Fluffeh
  • 33,228
  • 16
  • 67
  • 80
76

Just set these in php.ini:

upload_max_filesize = 1000M;
post_max_size = 1000M;
Pang
  • 9,564
  • 146
  • 81
  • 122
Altab Hossen
  • 877
  • 6
  • 4
36

1. First u will find the php.ini file.

u can find php.ini file from this path. C:\xampp\php or from xampp folder.

2. Now open php.ini file and change the following:

1. post-max-size (change 8M to 800M).

2. upload-max-filesize (change 2M to 2000M).

3. Now stop the Apache server and MySQL.

4. Now restart Apache server and MySQL.

It worked fine after that.

Enjoy ur working now :)

23

That's an 8MB post_max_size error.

Set it to a value you're comfortable with.

Mihai Stancu
  • 15,848
  • 2
  • 33
  • 51
18

You will have to change the value of

post-max-size
upload-max-filesize

both of which you will find in php.ini

Restarting your server will help it start working. On a local test server running XAMIP, i had to stop the Apache server and restart it. It worked fine after that.

Udhav Sarvaiya
  • 9,380
  • 13
  • 53
  • 64
Joel
  • 181
  • 1
  • 2
16

Already restarted your Webserver?

This will force php to reload the php.ini

MarcDefiant
  • 6,649
  • 6
  • 29
  • 49
13
  1. Create new text file in your wp-admin directory root and name it info.php.

  2. Open info.php and add this line:

    <?php phpinfo(); ?>

  3. Save it.

  4. Go to yourwebsitename(probably localhost)/wp-admin/info.php in any web-browser.

  5. On the 8th line you will see: Configuration File (php.ini) Path, in my case it is C:\Windows, meaning it is located on my C drive.

  6. In the 9th line you will see: Loaded Configuration File, and next to it is written C:\xampp\php.ini

So I found my php.ini page that is associated with my wordpress web-site.

  1. Go to that path, and find php.ini.

  2. Open it, and edit:

    Search for post_max_size=8M, and change it to post_max_size=1000M

    Search for upload_max_filesize=2M, and change it to upload_max_filesize=1000M

  3. Go back to your Admin page → Media → Add New

  4. On the bottom you will see that 2MB has changed to 1000M.

Once you done this process then you must restart your web server or just restart your computer.

pbarney
  • 2,529
  • 4
  • 35
  • 49
Sad Dam
  • 145
  • 1
  • 3
11

Go to C:\xamppp\php. Set these values in php.ini:

upload_max_filesize = 1000M
post_max_size = 0M
Paul Roub
  • 36,322
  • 27
  • 84
  • 93
6

Using wamp do the following and hopefully, it will resolve an issue

Make these changes in PHP Options to correct:

max_execution_time   180

memory_limit   512M or your highest available

post_max_size  32M

upload_max_filesize   64M
Udhav Sarvaiya
  • 9,380
  • 13
  • 53
  • 64
Fahad Ali
  • 97
  • 1
  • 4
6
  1. Find php.ini [\xampp\php]
  2. Just set these in php.ini:
upload_max_filesize = 1000M;
post_max_size = 1000M;
  1. Rebot server
    • Stop Apache and MySQL
    • Start again Apache and MySQL
Enaan Farhan
  • 111
  • 1
  • 4
5

Go to

C:\drive\xampp(where xampp installed)

simply find php.ini file then in the file search

post_max_size=XXM
upload_max_size=XXM

Change with this code

post_max_size=100M
upload_max_filesize=100M

Don't forget to restart the xampp

Khubaib Raza
  • 543
  • 6
  • 10
4

You also need the change post-max-size.

xdazz
  • 158,678
  • 38
  • 247
  • 274
4

From the XAMPP panel, click on the ADMIN button on the Apache site. Then choose to edit php.ini And add the missing post_max_size to a value you are comfortable with.

post_max_size = 100M
4

I have fixed same issue by changing below parameters to expected value in /etc/php/7.2/apache2/php.ini file

upload_max_filesize = 8M;
post_max_size = 8M;
Hasitha
  • 738
  • 8
  • 16
4
upload_max_filesize = 8M;
post_max_size = 8M;

Imagine you already changed above values. But what happen when user try to upload large files greater than 8M ?

This is what happen, PHP shows this warning!

Warning: POST Content-Length of x bytes exceeds the limit of y bytes in Unknown on line 0

you can avoid it by adding

ob_get_contents();
ob_end_clean();
Optimaz Prime
  • 857
  • 10
  • 11
3

Go to

C:\ drive

or that drive where xampp is installed click on xampp find php and open it , there you find php.ini folder open php.ini file with notepad and find upload_max_filesize and post_max_size in both "up and down find option",change both values to 1000M

Serjik
  • 10,543
  • 8
  • 61
  • 70
Zain
  • 31
  • 2
3

You have 2 options for this error:

  1. The file you are uploading is too big, which you need to use smaller file.
  2. Increase the upload size in php.ini to

upload_max_filesize = 9M; post_max_size = 9M;

Ustas
  • 370
  • 2
  • 8
  • 2
    I'll spare you the downvote as I'm sure you're trying to bump your reputation high enough to have useful privileges on this site, but this answer doesn't provide anything new or valuable that hasn't been said and upvoted many years prior. – tshimkus Jul 19 '20 at 01:46
2

Go to browser and search for php.ini and then open it, and change these two values:

post_max_size= 1000000000000M
upload_max_filesize= 10000000000000M

If you open the php.ini file using notepad , you can search for these two values by clicking:
cmd + f

Nimantha
  • 6,405
  • 6
  • 28
  • 69
2

for anyone running PHPMyAdmin inside of docker. Set the UPLOAD_LIMIT value in the env

from the docs https://github.com/phpmyadmin/docker#environment-variables-summary

UPLOAD_LIMIT - if set, this option will override the default value for apache and php-fpm (format as [0-9+](K,M,G) default value is 2048K, this will change upload_max_filesize and post_max_size values)

docker-compose.yml example:

phpmyadmin:
    image: phpmyadmin/phpmyadmin
    environment:
      - UPLOAD_LIMIT=300M

normal docker run:

sudo docker run .... -e UPLOAD_LIMIT=300M

For both of these options you have to rebuild the container

Linh Nguyen
  • 3,452
  • 4
  • 23
  • 67
1

You might not be uploading the right zip file. In my case, as a newbie to wordpress(I used to do hardcoding), I installed the zipped file that contained another zip file which is the actual theme neede to be upload. So what what need to do in this case is to unzip the file and locate the "theme_name.zip" inside.

papar
  • 1,023
  • 9
  • 17
1

If changing the post_max_size settings from XAMPP folders. It did not work for you try this.

From XAMPP control panel, click config then PHP (php.ini) and edit post_max_size and upload_max_filesize to a higher number in this file instead. Stop Apache server. Start Apache server. This worked for me.

Rohit.007
  • 3,414
  • 2
  • 21
  • 33
1

If your objective is to import a theme into your Wordpress then you can manually copy paste your theme into your wp-content->themes folder and extract it of course. I just encountered this and couldn't locate the php.ini file for WAMP.

1

I have solved my php7 issues on centos 7 by updating /etc/php.ini with these settings:

 post_max_size = 500M
 upload_max_filesize = 500M
Jim U
  • 3,318
  • 1
  • 14
  • 24
LEOTECH
  • 11
  • 1
0

As Optimaz ID pointed out, the code below helped me hide the PHP error message in a case where the user uploads a file larger than the upload_max_filesize and post_max_size set in php.ini (which is almost impossible when a large value is set).

ob_get_contents();
ob_end_clean();
-1

Warning: POST Content-Length of 9649253 bytes exceeds the limit of 8388608 bytes in Unknown on line 0 The link you followed has expired.