In a.php, data is submitted to b.php in POST mode, but b.php cannot receive the data, and the CURL operation shows success, which is very strange. It turns out that "when passing an array to CURLOPT_POSTFIELDS, cURL will encode the data into multipart/form-data, but when passing a URL-encoded string, the data will be encoded into application/x-www-form-urlencoded.
", and when people who are not familiar with CURL like me write programs, the code often looks like the following:
Copy the code The 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, and this will cause CURL Using the "wrong" encoding "multipart/form-data" has the same effect as directly using "