What is the size limit of a post request?
It depends on a server configuration. If you're working with PHP under Linux or similar, you can control it using .htaccess configuration file, like so:
#set max post size
php_value post_max_size 20M
And, yes, I can personally attest to the fact that this works :)
If you're using IIS, I don't have any idea how you'd set this particular value.
Get byte size of http request in PHP
I found out that the best way for getting this for my use is by using:
$size = @file_get_contents('php://input');
Thanks for the help guys!
Check sent $_POST size
If you are trying to measure the size of the request, the $_SERVER superglobal has a property for this.
$size = (int)$_SERVER['CONTENT_LENGTH'];
Submit your post to an endpoint with this code and echo it's value.
This will assign the value of the Content-length HTTP header to $size if the request was sent via the POST method.
How can I check the POST data size before I submit it with jQuery?
You can estimate it by counting the length of your serialized form, excluding file upload fields. So it would be somewhere along these lines:
$("form").not("[type='file']").serialize().length
;
How to get php://input size?
php://input
is not a file, so fstat()
doesn't have anything to process.
So, yes, you are going to have to special-case php://input
Related Topics
Insert PHP Code in Wordpress Page and Post
Php: How to Resolve a Relative Url
PHP Function for Get All Mondays Within Date Range
Laravel - Using (:Any) Wildcard for All Routes
Relative Path Not Working in Cron PHP Script
How to Pass an Array via $_Get in PHP
How to Check If a Request If Coming from the Same Server or Different Server
How to Auto Call Function in PHP for Every Other Function Call
PHP Can't Connect to MySQL with Error 13 (But Command Line Can)
How to Place Two Forms on the Same Page
How to Pull First 100 Characters of a String in PHP
Using If(Isset($_Post['Submit'])) to Not Display Echo When Script Is Open Is Not Working
Pg_Query Result Contains Strings Instead of Integer, Numeric
How to Check Which PHP Extensions Have Been Enabled/Disabled in Ubuntu Linux 12.04 Lts