In a. php, data is submitted to B. php In POST mode, but data cannot be received in B. php, And the CURL operation is displayed as successful, which is very strange. It turns out that "when an array is passed to CURLOPT_POSTFIELDS, cURL will encode the data into multipart/form-data. When the handler passes a URL-encoded string, the data is encoded into application/x-www-form-urlencoded.
", While people who are not familiar with CURL, like me, often look like the following code when writing a program:
Copy codeThe Code is as follows:
$ Data = array ('title' => $ Title, 'content' => $ Content, 'comefrom' => $ ComeFrom );
Curl_setopt ($ ch, CURLOPT_DNS_USE_GLOBAL_CACHE, false );
Curl_setopt ($ ch, CURLOPT_URL, 'HTTP: // example.com/ B .php ');
Curl_setopt ($ ch, CURLOPT_POST, 1 );
Curl_setopt ($ ch, CURLOPT_POSTFIELDS, $ data );
Curl_exec ($ ch );
That is, the data to be submitted is sent through POST in the form of an array, which causes CURL to use the "error" encoding "multipart/form-data ", the effect is equivalent to "<form method =" post "action =" B. php "enctype =" multipart/form-data ">" to complete the operation, you can try it. php "cannot receive data through $ _ POST in any way.
Therefore, the correct method should be to change the $ data in the above sample code from an array to URL code () encoded.