Asked  7 Months ago    Answers:  5   Viewed   37 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

85

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.

Wednesday, March 31, 2021
 
etsous
answered 7 Months ago
38

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.

Wednesday, March 31, 2021
 
dirigibleplum
answered 7 Months ago
88

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)

Friday, June 11, 2021
 
tadman
answered 5 Months ago
88

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).

Friday, August 6, 2021
 
kamikaze_pilot
answered 3 Months ago
74

I had the same problem recently.

I did these 3 things and it worked:

  1. Made sure the Collation of the exported database is the same as the newly created one.

  2. Made these changes in my php.ini(xampp/php/php.ini) file

    max_execution_time = 5000
    max_input_time = 5000
    memory_limit = 1000M
    post_max_size = 750M
    upload_max_filesize = 750M
    
  3. Made this change in my phpmyadminlibrariesconfig.default.php file:

change

$cfg['ExecTimeLimit'] = 300;

to

$cfg['ExecTimeLimit'] = 0;

(So there is no limit)

Sunday, August 8, 2021
 
Kai
answered 3 Months ago
Kai
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :
 
Share