Viewed   432 times

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?

 Answers

5

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.

Friday, September 2, 2022
3

Found an alternative solution that does not deal with the error directly. The following code is written by a software engineer Andrew Curioso in his blog:

if($_SERVER['REQUEST_METHOD'] == 'POST' && empty($_POST) &&
     empty($_FILES) && $_SERVER['CONTENT_LENGTH'] > 0)
{
  $displayMaxSize = ini_get('post_max_size');

  switch(substr($displayMaxSize,-1))
  {
    case 'G':
      $displayMaxSize = $displayMaxSize * 1024;
    case 'M':
      $displayMaxSize = $displayMaxSize * 1024;
    case 'K':
       $displayMaxSize = $displayMaxSize * 1024;
  }

  $error = 'Posted data is too large. '.
           $_SERVER[CONTENT_LENGTH].
           ' bytes exceeds the maximum size of '.
           $displayMaxSize.' bytes.';
}

As explained in his article, when the post size exceeds post_max_size, the super global arrays of $_POST and $_FILES will become empty. So, by testing for these and by confirming that there is some content being sent using the POST method, it can be deduced that such an error has occurred.

There is actually a similar question here, which I didn't manage to find earlier.

Friday, November 18, 2022
 
3

Go to wp-config.php, set WP_DEBUG to true and see what happens.

Tuesday, November 1, 2022
 
2

On some 32bit systems PHP will take the memory settings like 2000M or 2G and convert it to the integer number of bytes by not performing a boundary check. A number starting at 2G or 2048M will be -2147483648 bytes then.

Some PHP versions cap this at the top, so it won't go into negative numbers (that is the 32 bit signed integer limit).

If you want to achieve the maximum possible number of bytes on such a system then, use 2147483647. This is equal to two gigabytes minus one byte.

Alternatively if you need to deal with large data, consider a 64bit system.

Additionally you should consider the following:

According to the PHP manual, the memory_limit setting is the more important one. If it does not offer enough memory, the post-data size-check then will pass, but PHP would not have enough memory to actually handle the post-data. You will get another error than, that the memory exceeded. So when you configure your PHP, take care that post_max_size is smaller than memory_limit.

In your example the memory_limit is 128M, so it can not process post-data of a size larger than ~128 Megabyte.

(This blog post shows what can happen and how large memory settings on 32bit and 64bit systems behave)

Saturday, September 24, 2022
 
4

By default, Xampp has FollowSymlinks disabled. See point 4 on how to

  • enable mod rewrite (if not done already)
  • set AllowOverride from none to all

https://codex.wordpress.org/Using_Permalinks#Fixing_Permalink_Problems

If AllowOverride is not set to all, permalinks will cause exactly these 404 errors you describe ("Not found" on existing pages).

Sunday, December 4, 2022
 
simao
 
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :
 
Share