Reputation: 686
I am writing a cURL with PHP without specifying the Content-type in the header, I set the post fields as below and it works. My question is how do I know if it is sent by multipart/form-data or not?
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($_POST) );
Upvotes: 0
Views: 165
Reputation: 11829
CURLOPT_POSTFIELDS
If value is an array, the Content-Type header will be set to multipart/form-data.
If value is a string, like in your code, Content-Type will be set to application/x-www-form-urlencoded
You can see request headers by following code:
$request_headers = curl_getinfo($ch, CURLINFO_HEADER_OUT);
var_dump($request_headers);
Upvotes: 2