curlform_contenttype 种类curl中form表单提交的Content-Type种类有: application/x-www-form-urlencoded:默认的形式,即key1=value1&key2=value2的形式。 multipart/form-data:使用表单上传文件时使用这个形式。 application/json:提交JSON格式的数据。 text/xml:提交XML格式的数据。
$data["file"] = "@/image.jpg;type=image/jpeg"; //make the POST request $curl = curl_init(); curl_setopt($curl, CURLOPT_URL,$url); curl_setopt($curl, CURLOPT_VERBOSE, 1); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_HTTPHEADER, $header); ...
curl -d "param1=value1¶m2=value2" -H "Content-Type: application/x-www-form-urlencoded" -X POST http://localhost:3000/data
But curl 7.44.0 ( x86_64 / Linux ) is deciding to append an extra 'Content-Type: application/x-www-form-urlencoded' header: 03be: Accept: application/vnd.newbay.dv-1.3+json 03ea: Content-Type : application/octet-stream 0413: Content-Length: 524288 ...