// 以POST方式提交数据 public function post_data($url, $param, $is_file = false, $return_array = true) { ........ $ch = curl_init (); curl_setopt ( $ch, CURLOPT_URL, $url ); curl_setopt ( $ch, CURLOPT_CUSTOMREQUEST, "POST" ); curl_setopt ( $ch, CURLOPT_SSL_VERIFYPEER, FALSE ); curl_setopt ( $ch, CURLOPT_SSL_VERIFYHOST, FALSE ); curl_setopt ( $ch, CURLOPT_HTTPHEADER, $header ); curl_setopt ( $ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)' ); curl_setopt ( $ch, CURLOPT_FOLLOWLOCATION, 1 ); curl_setopt ( $ch, CURLOPT_AUTOREFERER, 1 ); curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, true ); if($is_file){ if(version_compare(phpversion(),'5.6')>=0){ if(version_compare(phpversion(),'7')>=0){ $param['media'] = new CURLFile(ltrim($param['media'], '@')); }else{ curl_setopt ( $ch, CURLOPT_SAFE_UPLOAD, false); } } } curl_setopt ( $ch, CURLOPT_POSTFIELDS, $param ); $res = curl_exec ( $ch ); curl_close ( $ch ); ....... return $res; }