美文网首页
PHPcurl 、curl请求,取消Content-Dispos

PHPcurl 、curl请求,取消Content-Dispos

作者: 可乐_加冰_ | 来源:发表于2020-08-10 15:46 被阅读0次
    关于php curl请求,自动生成的:
    ------------------------------76e7fd6813a5 Content-Disposition: form-data, name
    
      需设置http_build_query()即可:curl_setopt ( $curl, CURLOPT_POSTFIELDS,http_build_query($data))
    
    <?php
        public function cur_post($url,$data){
            $curl = curl_init();
            curl_setopt($curl, CURLOPT_URL, $url);
            curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);// https请求 不验证证书和hosts
            curl_setopt($curl, CURLOPT_HEADER, 0);
            curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10000);
            curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type:application/x-www-form-urlencoded'));
            curl_setopt ( $curl, CURLOPT_POSTFIELDS,http_build_query($data));//数据过滤,去掉curl自动生成的参数:------------------------------76e7fd6813a5\r\nContent-Disposition: form-data
            //curl_setopt($curl, CURLOPT_POSTFIELDS, $data);//设置post数据
            $res = curl_exec($curl);//执行命令
            curl_close($curl);
            return $res;
        }
    
    
    摘自:https://blog.csdn.net/veloi/article/details/80146660
    
    

    相关文章

      网友评论

          本文标题:PHPcurl 、curl请求,取消Content-Dispos

          本文链接:https://www.haomeiwen.com/subject/cysjdktx.html