PHP使用curl请求multipart/form-data 方式

PHP请求数据同个curl的multipart/form-data方式请求,详细如下方法public function facecurl($url,$bodys){ $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT

PHP请求数据同个curl的multipart/form-data方式请求,详细如下方法

public  function facecurl($url,$bodys){
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_USERAGENT,'Opera/9.80 (Windows NT 6.2; Win64; x64) Presto/2.12.388 Version/12.15');
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); // stop verifying certificate
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_POST, true);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $bodys);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $r = curl_exec($curl);
    curl_close($curl);
    return $r;

}

本文标题为:PHP使用curl请求multipart/form-data 方式

基础教程推荐