1

When I try to post to a php file, some data of JSON file are lost. I have a JSON-file with 1100 entries. On my server, I can only add 333 entries. On another server, I can add 1000 entries. Do I have to change my server configuration?

JSON File has 1100 entries (users)

Jquery:

$.post(
  'store.php',
  {json:usersJSON},
  {contentType: "application/json"}, 
  function() {
    alert(data);
  });

PHP:

$JSON = $_POST['json'];
echo json_encode($JSON);

on one server, this echoes 333 entries, on the other server, it echoes 1000 entries

7
  • Can you confirm that you are sending the same data to both servers? Commented Feb 28, 2013 at 11:48
  • If it's a JSON file, why are'nt you just getting it with PHP ? Commented Feb 28, 2013 at 11:49
  • Check the php.ini for post_max_size and check PHP error log for any errors Commented Feb 28, 2013 at 11:55
  • before you can use json_encode need to first use json_decode to turn string received into array Commented Feb 28, 2013 at 11:56
  • @cwallenpoole the exact same data is sent Commented Feb 28, 2013 at 12:15

3 Answers 3

2

The problem was max_input_vars in my php.ini file. It was set to 1000. That means I could add a json-file with 1000 entries with one field, or 500 entries with 2 fields,...

I set max_input_vars to 5000, now I can post a json-file with 1666 entries with 3 fields.

Sign up to request clarification or add additional context in comments.

Comments

0

How large are your entries? It might be the server limiting your posts. Try looking at the post_max_size directive in php.ini

1 Comment

entries are under 5mb, as they are locally stored in html5 localStorage. post_max_size is 8mb ...
0

This is probably due to your server's configuration. Check php.ini for the setting max_post_size and ensure that it is sufficiently large to post your data. Also check your web server settings - Apache has a LimitRequestBody directive which could be causing your problem. Finally, check your web server and PHP error logs to see if the large post is triggering any errors.

source

6 Comments

post_max_size is 8 mb. JSON File is under 8 MB, as it is stored in localStorage. I will check the LimitRequestBody directive
So I changed post_max_size to 20M, without any change. I looked for LimitRequestBody in my httpd.conf and htaccess, but didn't find it. Tried to add LimitRequestBody 0 in my httpd.conf, without change? Any other ideas?
@TomBroucke Not on top of my head, sorry. Have you looked in the link that i posted?
My json-file is like: {"users":[{"name":"myName","email":"myEmail","comment":"myComment"}]} This way, I can get 333 items to my PHP-file. If i only add the name, I can send 1000 items to my PHP-file. I tried to edit max_input_vars (was 1000 originally). It changed in PHP.ini, but it's still 1000 if I check phpinfo()
max_input_vars was still commented, but still no change
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.