This is my current code i am using to saveguard user post through form
$data_=$_POST['main_data']; $size=strlen($data_); $size=$size/1000; if( $size>500){ //i.e if greater than 500kb echo '__DATA_TOO_LARGE__'; exit; }
If main_data
is a correct data which is less than 500kb (i did with 400kb), the speed at which it uploads is super fast, but i noticed that if i paste a very large texts in the form, it takes longer before it shows error text.
I thought this line:
if( $size>500){ //i.e if greater than 500kb echo '__DATA_TOO_LARGE__'; exit; }
should stop uploading immediately it hits 500kb marks but it seems i’m wrong and am forced to ask.
Will php accepts the whole post data before it reaches my post limit condition?
What if a user tries to post too large texts in the form deliberately or not, will it affect my website bandwidth usage.
If it will, any work around such scenario to prevent the too large data?
Even though i can limit the text length with javascript but user can disable javascript.
Advertisement
Answer
1. Will php accepts the whole post data before it reaches my post limit condition?
Yes
2. What if a user tries to post too large texts in the form deliberately or not, will it affect my website bandwidth usage.
Yes
3. If it will, any work around such scenario to prevent the too large data?
This is in php.ini settings. See the link.