Ошибка post content length of

I get similar errors in my error_log in php when users are uploading their files

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

In my php.ini (created custom ini file in public_html) would this solve this problem, how much would I have to set it to around 1GB? I am going to change my settings to this in php.ini, will it solve the problem?

upload_max_filesize = 1000M ;1GB
post_max_size = 1000M

What would I set the ‘memory_limit’ limit to.

Also would this be correct in my script to check file uploaded size is <1GB

if($_FILES["uploadedfile"]["size"]<1000000)

asked Jun 8, 2011 at 13:59

daza166's user avatar

7

8388608 bytes is 8M, the default limit in PHP. Those changes to php.ini should indeed solve the problem (make sure your restart your Apache server after making them).

Memory limit shouldn’t need to be changed here.

answered Jun 8, 2011 at 14:02

ceejayoz's user avatar

ceejayozceejayoz

176k40 gold badges299 silver badges365 bronze badges

5

I suggest that you should change to post_max_size from 8M to 32M in the php.ini file.

John's user avatar

answered Jul 18, 2012 at 2:29

manson's user avatar

mansonmanson

4814 silver badges2 bronze badges

you just setting at php.ini

then set :

upload_max_filesize = 1000M;
post_max_size = 1000M;

then restart your xampp..
Check the image

rink.attendant.6's user avatar

answered Sep 15, 2013 at 8:06

Farid Blaster's user avatar

Farid BlasterFarid Blaster

9741 gold badge9 silver badges23 bronze badges

0

Try pasting this to .htaccess and it should work.

php_value post_max_size 2000M
php_value upload_max_filesize 2500M
php_value max_execution_time 6000000
php_value max_input_time 6000000
php_value memory_limit 2500M

rink.attendant.6's user avatar

answered Jan 11, 2015 at 3:29

Mel's user avatar

MelMel

2092 silver badges4 bronze badges

1

post_max_size should be slightly bigger than upload_max_filesize, because when uploading using HTTP POST method the text also includes headers with file size and name, etc.

If you want to successfully uppload 1GiB files, you have to set:

upload_max_filesize = 1024M
post_max_size = 1025M

Note, the correct suffix for GB is G, i.e. upload_max_filesize = 1G.

No need to set memory_limit.

answered Nov 28, 2014 at 16:42

ArticIceJuice's user avatar

1

In Some cases, you need to increase the maximum execution time.

max_execution_time=30

I made it

max_execution_time=600000

then I was happy.

answered Dec 5, 2013 at 22:02

Traveling Salesman's user avatar

1

There might be more than just one php.ini file. For example, when using WAMP there are 2 php.ini files in following directories:

  • C:wampbinapacheapache2.4.9bin
  • C:wampbinphpphp5.5.12

You need to edit the first one.

sepehr's user avatar

sepehr

16.9k7 gold badges80 silver badges119 bronze badges

answered May 20, 2015 at 5:53

Irfandi D. Vendy's user avatar

0

I disagree, but the solution to increase the file size in php.ini or .htaccess won’t work if the user sends a file larger than allowed by the server application.

I suggest validating this on the front end. For example:

$(document).ready(function() {
    $ ('#your_input_file_id').bind('change', function() {
        var fileSize = this.files[0].size/1024/1024;
        if (fileSize > 2) { // 2M
            alert('Your custom message for max file size exceeded');
            $('#your_input_file_id').val('');
        }
    });
});

pbarney's user avatar

pbarney

2,5014 gold badges34 silver badges49 bronze badges

answered Jun 30, 2017 at 2:28

Marcio Muzzi's user avatar

4

If you are using Php 5.6.X versions in windows using Wamp, then file location may be in,

C:Windowsphp.ini

Just try with

post_max_size = 100M;

Try to do changes in Apache one. By that your Wamp/XAMP load .ini file

Edward Peters's user avatar

answered Jul 26, 2016 at 16:46

Satyanarayana's user avatar

If you are using Laravel and using artisan:serve for running Laravel project you create php.ini in your public directory, then you can specify your configuration.

  • file_uploads = On
  • max_execution_time = 300
  • post_max_size = 20480M
  • upload_max_filesize = 20480M

answered Sep 14, 2021 at 11:07

ADRIS MALYA's user avatar

In this tutorial, we are going to show you how to fix the following PHP warning:

PHP Warning: POST Content-Length of 77870742 bytes exceeds the limit of 8388608 bytes.

This error will occur if the size of a POST request is larger than the limit in your “post_max_size” directive.

If you look at the message carefully, you can see that the Content-Length of the POST request in this case was 77,870,742 bytes. That is roughly 77.87MB.

This is a problem, as the post_max_size directive in our php.ini file is 8,388,608 bytes (8MB).

By default, PHP’s post_max_size directive will be 8MB.

To sum up the issue in this particular case:

  • The size limit for a POST request is 8MB.
  • However, the size of our POST request is 77.87MB.

As you can see, it is well over the limit. Consequently, both the $_POST and $_FILES superglobal arrays will be empty.

This kind of error is particularly common with file uploads, as the size of an uploaded file can easily surpass the 8MB limit that has been set down in php.ini.

For example, a small video file could end up being 100MB or more. A form that allows the user to upload multiple files at once will also easily surpass this limit.

What is my post_max_size setting?

Here is a quick way to determine what your current post_max_size setting is:

//Print out the value of the post_max_size directive.
echo ini_get('post_max_size');

In the PHP snippet above, we printed out the value of the post_max_size setting by using the ini_get function.

In most cases, this will say “8M”.

How to increase your post_max_size setting.

To increase the size limit of your POST requests, you will need to locate your php.ini file and change the post_max_size directive.

By default, it will look like this:

post_max_size = 8M

As you can see, it is currently 8MB. If we want to change this limit to 32MB, then we will need to change the directive to:

post_max_size = 32M

PHP also allows you to specify gigabytes by using the G character:

post_max_size = 1G

In the example above, we set the maximum size of POST data to one gigabyte. Note that you can also completely disable the max size by setting the value to 0 like so:

post_max_size = 0

This will only work if you are using PHP version 5.2.12 or above. However, I would recommend that you do not disable this limit unless you’re 100% sure that you know what you are doing.

Make sure that you save the file and reload your web server after changing this directive. Otherwise, the older limit value will remain in memory.

Can I use the ini_set function to change the post_max_size directive?

The post_max_size directive cannot be changed by using PHP’s ini_set function. Therefore, using the following piece of code will not work:

//Attempting to use ini_set to change post_max_size
echo ini_set('post_max_size', '100M');

This is because the directive has a Changeable Mode Value of PHP_INI_PERDIR.

You can change this setting in a php.ini, .htaccess, httpd.conf or .user.ini file.

However, you will be unable to do so using ini_set.

Warning Post Content-Length Exceeds The Limit of 8388608 bytes in Unknown on line 0

Are you facing this post content length exceeding the limit of 8388608 bytes in Unknown on line 0? Why You are getting this Error Do you know?

Post-Content-Length Exceeds The Limit error you are getting because your upload size of the theme is more than the set file-max upload file size in php.ini

Gomahamaya ads banner

You may also be interested in Fomo Plugins, Email marketing Service and Page Builder Tool 

semrush Free trail banner

How  to resolve Warning: Post Content-Length Exceeds The Limit of 8388608 bytes in Unknown on line 0

Warning: Post Content-Length Exceeds The Limit Of 8388608 Bytes In Unknown On Line 0

1. Go to c drive of your computer

2. In c drive of your compute to search for xampp folder

xampp folder

3. In cdrive–> xampp –> then you need to search for PHP folder then open that PHP folder

php folder highlighted

4. Inside PHP folder you need to search for PHP note pad file just beside that PHP you will find configuration setting

5. open that php note pad file and open a find box type ctrl+f (window ) command+f(mac) and in that find box search for post_max_size=8M and now increase the 8M to 8000M so your final code will post_max_size=8000M

kwfinder banner

8m highlighted

6. And now you need to search for upload_max_filesize=2M then increase the file size to 20000M so now your final code     will upload_max_filesize=20000M and now save that notepad file

2000 mb highlighted

7. Now go back to your xampp Cpanel and restart it stop or else you will get an error(MUST)

Kinsta banner promo material

Xampp

Now Bingo no more Post Content-Length Exceeds The Limit error

Fastcomet banner
Gomahamaya ads banner

Author: Rahul Sahu

Hii all! I am Rahul. I love to design optimized and secure website. I am also a full-time Youtuber and blogger whereby I create content to help the non-technical audience.

This PHP Warning error occurs because the data being posted is larger than the maximum size allowed by the PHP configuration.

To resolve this, you need to increase the post_max_size directive in your PHP configuration file. This directive sets the maximum size of POST data that PHP will accept. By default, the value is usually set to 8MB.

To increase the post_max_size the directive, follow these steps:

Step 1: Locate your PHP configuration file

The location of your PHP configuration file depends on your operating system and the web server. Here are some common locations:

  • CentOS: /etc/php.ini
  • Ubuntu: /etc/php/7.2/apache2/php.ini
  • XAMPP: /opt/lampp/etc/php.ini
  • WAMP: C:wamp64binphpphp7.4.9php.ini

If you’re not sure where your PHP configuration file is located, you can create a new PHP file with the following code:

<?php
phpinfo();
?>

Save the file in your web server’s root directory and access it via a web browser. Look for the “Loaded Configuration File” row to find the location of your PHP configuration file.

Step 2: Edit the post_max_size directive

Once you’ve located your PHP configuration file, open it in a text editor and search for the post_max_size directive. If it’s not there, you can add it to the end of the file. The line should look like this:

post_max_size = 8M

Change the value to a higher number, like 16M. Make sure to use the appropriate unit (M for megabytes, K for kilobytes, G for gigabytes). The new line should look like this:

post_max_size = 16M

Step 3: Edit the upload_max_filesize directive

The upload_max_filesize the directive sets the maximum size of uploaded files. You should set this value to the same or a higher value than post_max_size.

Search for the upload_max_filesize the directive in your PHP configuration file and modify it as follows:

upload_max_filesize = 16M

Step 4: Save and restart your web server

Save your changes to the PHP configuration file and restart your web server to apply the new settings. The method for restarting your web server varies depending on your operating system and the web server. Here are some common methods:

  • CentOS: sudo service httpd restart
  • Ubuntu: sudo systemctl restart apache2
  • XAMPP: Click the “Stop” button and then the “Start” button in the XAMPP control panel
  • WAMP: Click the “Restart All Services” button in the WAMP control panel

After restarting your web server, the “PHP Warning: POST Content-Length of 8978294 bytes exceeds the limit of 8388608 bytes in Unknown on line 0” error message should no longer appear. You can now submit your form or upload your file without any issues.

In conclusion, to resolve the “PHP Warning: POST Content-Length of 8978294 bytes exceeds the limit of 8388608 bytes in Unknown on line 0” error message, you can increase the post_max_size and upload_max_filesize directives in your PHP configuration file and restart your web server.

Currently when user uploads a photo the page says «Warning: POST Content-Length of XXX bytes exceeds the limit of 21000000 bytes in Unknown on line 0″.

I know what that means and I am NOT looking for the solultions like the increasing the max_upload values or even memory_size_limit… Because users may and users will upload terabytes of nonsense even if you explicitly tell them only max 20MB files and only images are allowed.

I am looking for a solution on:

  • How to prevent this warning(s) to even happen?

    OR at least:
  • How to prevent displaying of this warning(s)?

EDIT: PLEASE READ ! — Please understand that of course I am handling the error/warning after (since line 1) , problem is this happens on a virtual «line 0» that is why I need to hide the error or prevent it to raise — because I cant put any code before the place where the error happens.

EDIT2: Finally after a very long research and digging I got an idea — it worked — see my own answer.

Why does PostPost-content-length exceeds the limit?

Post-Content-Length Exceeds The Limit error you are getting because your upload size of the theme is more than the set file-max upload file size in php.ini You may also be interested in Fomo Plugins, Email marketing Service and Page Builder Tool

What is the content-length of POST request in PHP?

PHP Warning: POST Content-Length of 77870742 bytes exceeds the limit of 8388608 bytes. The error message above will occur if the size of a POST request exceeds the limit that has been set in the post_max_size directive in your php.ini file.

How to fix the PHP error post content-length of X bytes exceeds?

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 8388608 bytes is 8M, the default limit in PHP. Update your post_max_size in php.ini to a larger value.

What is the size limit for a POST request?

The size limit for a POST request has been set to 8MB. However, the size of our POST request is 77.87MB. As you can see, it is well over the allowed limit.

So after searching instead of working today I finally got an idea how to solve this, it worked, and even didnt cause much damage. But please first understand what you are doing, before doing it. :) As I suggested in one of my comments it is really possible to turn off PHP errors in .htacess — just turn off the PHP startup warnings.

Before you apply the solution:

Note that: after you insert this code to your .htaccess you won’t be able to see any
startup error

Also note that: there are more start up errors on line «0» than this one.

Do before: Before you do this you should prepare your script in the way that it should check the uploaded content size and give user a proper information message. The fact that the warning doesnt show DOES NOT mean that you should do nothing about it. It means the EXACT oposite — you should do all that you can to make something at least near-equal to the warning raise — check, double check if you can, handle error and raise your own error message.

Add this to your .htaccess:

php_flag display_startup_errors off

It is not that evil as it seems to be:

Please note that this turns off startup errors only.

So all the regular PHP errors/warnings/notices stays ON :)

Even XAMPP’s PHP «itself» recommends it for production:

The php.ini file literaly says:

; display_startup_errors
;   Default Value: Off
;   Development Value: On
;   Production Value: Off

PS: «startup error» seems to be those errors before PHP script is executed itself — these errors are usually trying to «persuade» you that they are on the line 0.

Thanks to my idea and this answer: How to disable notice and warning in PHP within .htaccess file?

EDIT: As this is a php_flag setting, you can of course also set it by default in your php.ini if you have custom instalation of PHP :)

The question is

How to prevent Warning: POST Content-Length

the answer is, without edit any config value, put this code at the very start of the file that will receive the form to be processed:

 <?php // here start your php file
 ob_get_contents();
 ob_end_clean();

That is. No more warning, as well anything else you do not want as output on your page.
After, as suggested elsewhere you can decide what to do with:

if($_SERVER['REQUEST_METHOD'] == 'POST' && empty($_POST) && empty($_FILES) && $_SERVER['CONTENT_LENGTH'] > 0){ echo"WoW your file is too big!"; }

Maybe also chunk the file, if in another way you pass correct values about file to be processed by Php.

as explained here Warning: POST Content-Lenght …

Понравилась статья? Поделить с друзьями:
  • Ошибка please wait point blank
  • Ошибка please verify game cache integrity
  • Ошибка please update you intel driver
  • Ошибка please select boot device
  • Ошибка please run windows update your system is lacking