POST Content-Length exceeds the limit

Php

Php Problem Overview


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)

Php Solutions


Solution 1 - Php

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.

Solution 2 - Php

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

Solution 3 - Php

you just setting at php.ini

then set :

upload_max_filesize = 1000M;
post_max_size = 1000M;

then restart your xampp.. Check the image

Solution 4 - Php

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

Solution 5 - Php

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.

Solution 6 - Php

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.

Solution 7 - Php

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:\wamp\bin\apache\apache2.4.9\bin
  • C:\wamp\bin\php\php5.5.12

You need to edit the first one.

Solution 8 - Php

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('');
        }
    });
});

Solution 9 - Php

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

C:\Windows\php.ini

Just try with

post_max_size = 100M;

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

Solution 10 - Php

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questiondaza166View Question on Stackoverflow
Solution 1 - PhpceejayozView Answer on Stackoverflow
Solution 2 - PhpmansonView Answer on Stackoverflow
Solution 3 - PhpFarid BlasterView Answer on Stackoverflow
Solution 4 - PhpMelView Answer on Stackoverflow
Solution 5 - PhpArticIceJuiceView Answer on Stackoverflow
Solution 6 - PhpTraveling SalesmanView Answer on Stackoverflow
Solution 7 - PhpIrfandi D. VendyView Answer on Stackoverflow
Solution 8 - PhpMarcio MuzziView Answer on Stackoverflow
Solution 9 - PhpSatyanarayanaView Answer on Stackoverflow
Solution 10 - PhpADRIS MALYAView Answer on Stackoverflow