0

I want to ask that how can I get the size of data I am passing as a client to the server.As while developing an application, I am unable to get the whole data on server side.My POST limit size at the server side is 6M as in php.ini file.

I have asked a similar question earlier(How to parse large data via POST query), but didn't get a prompt answer.

Thanks

Pravitha V
  • 3,308
  • 4
  • 33
  • 51
confused
  • 77
  • 8
  • then increase the post limit size to 22m in php.ini – Krishna Satya Aug 23 '17 at 04:41
  • Possible duplicate of [Increasing the maximum post size](https://stackoverflow.com/questions/6135427/increasing-the-maximum-post-size) – Doomenik Aug 23 '17 at 04:46
  • my (int) $_SERVER['CONTENT_LENGTH']= 3598 and post_max_size in php.ini =6M .So , is it justified that i am not getting full data i am parsing? – confused Aug 23 '17 at 05:06
  • you have not described the problem (i.e. what is it that is not working) but rather your assumption as to its root cause. C'mon, cought it up : how is this not working, and how do you assert the incorrect behaviour. – YvesLeBorg Aug 23 '17 at 05:10
  • It is not working coz when i alert the datastring i am sending to server,i can see all the stuff i am sending.But at the server side when i alert the maker , i.e the last key-value pair of datastring , i am getting that, but i am not getting the $all_data which contains the data in the rows of the handsontable on the front-end , that the user has entered. – confused Aug 23 '17 at 05:19
  • ah ... u just went over to your other question. You are sending this on the url, and 3598 maybe larger than you can handle in your browser, see **[this related question](https://stackoverflow.com/questions/29458445/what-is-a-safe-maximum-length-a-segment-in-a-url-path-should-be)**. Try to post that as json in the body of the request. – YvesLeBorg Aug 23 '17 at 05:42
  • What does "try to post as json" mean , as you can see in my post(https://stackoverflow.com/questions/45581331/how-to-parse-large-data-via-post-query?noredirect=1#comment78147038_45581331) , i have used json.stringify. – confused Aug 23 '17 at 07:06

2 Answers2

1

Try this:

$data_size = (int) $_SERVER['CONTENT_LENGTH'];
Abe
  • 1,357
  • 13
  • 31
0

Please use this function on submit form

<button onclick="store()" type="button">form submit</button>

function store(){     
    var totalsize = 0;    // total post data size
    $('form').find('input[type=file]').each(function() { // for all files in form
        totalsize += this.files[0].size;
    });

    totalsize=totalsize+($("form").not("[type='file']").serialize().length);

    if (totalsize > (6 * 1048576)) { // > 6MB   
        // this will exceed post_max_size PHP setting, now handle...

        alert('this will exceed post_max_size PHP setting')
    } else if ($('form').find('input[type=file]').length >= 10) { // max_file_upload_limit = 10; 
        // if file upload is more than 10
         alert('upload is more than 10 files')
    }else{

      you are free upload data successfully
    }
}
hiren207
  • 184
  • 6
  • i am not uploading a file but rows of handson table .Please see my this question https://stackoverflow.com/questions/45581331/how-to-parse-large-data-via-post-query?noredirect=1#comment78147038_45581331 – confused Aug 23 '17 at 05:02