php - Warning: Input variables exceeded 1000 -


i'm building rests service in php should accept large json post main data (i send , read data discussed here: http://forums.laravel.io/viewtopic.php?id=900)

the problem php gives me following warning:

<b>warning</b>:  unknown: input variables exceeded 1000. increase limit change max_input_vars in php.ini. in <b>unknown</b> on line <b>0</b><br /> 

is there way php not count input variables (or should surpress startup warnings)?

i found out right way handle json data directly in php (via file_get_contents('php://input')) make sure request sets right content-type i.e. content-type: application/json in http request header.

in case i'm requesting pages php using curl code:

function curl_post($url, array $post = null, array $options = array()) {   $defaults = array(     curlopt_post => 1,     curlopt_header => 0,     curlopt_url => $url,     curlopt_fresh_connect => 1,     curlopt_returntransfer => 1,     curlopt_forbid_reuse => 1,     curlopt_timeout => 600   );   if(!is_null($post))     $defaults['curlopt_postfields'] = http_build_query($post);   $ch = curl_init();   curl_setopt_array($ch, ($options + $defaults));   if(($result = curl_exec($ch)) === false) {     throw new exception(curl_error($ch) . "\n $url");   }   if(curl_getinfo($ch, curlinfo_http_code) != 200) {     throw new exception("curl error: ".        curl_getinfo($ch, curlinfo_http_code) ."\n".$result . "\n");   }   curl_close($ch);   return $result; }  $curl_result = curl_post(url, null,     array(curlopt_httpheader => array('content-type: application/json'),       curlopt_postfields => json_encode($out))     ); 

do note curlopt_httpheader => array('content-type: application/json') part.

on receiving side i'm using following code:

$rawdata = file_get_contents('php://input'); $postedjson = json_decode($rawdata,true); if(json_last_error() != json_error_none) {   error_log('last json error: '. json_last_error().      json_last_error_msg() . php_eol. php_eol,0); } 

do not change max_input_vars variable. since changing request set right headers issue max_input_vars went away. apparently not php evaluate post variables content-type set.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -