本文实例讲述了PHP CURL实现模拟登陆并上传文件操作。分享给大家供大家参考,具体如下:

<"");
//  curl_setopt($ch, CURLOPT_ENCODING, 'gzip,deflate');
  curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post_data));
  //执行并获取结果
  $output = curl_exec($ch);
  if($output === FALSE)
  {
    echo "<br/>","cUrl Error:".curl_error($ch);
  }else{
    return $output;
  }
  //  释放cURL句柄
  curl_close($ch);
}
$temp = array();
$temp['title'] = iconv( "utf-8", "gb2312//IGNORE" , "牛排店加盟");
$temp['ly'] = iconv( "utf-8", "gb2312//IGNORE" , "特色餐饮加盟");
$temp['classid'] = iconv( "utf-8", "gb2312//IGNORE" , "7159");
$temp['newssort'] = iconv( "utf-8", "gb2312//IGNORE" , "1");
$temp['panduan'] = iconv( "utf-8", "gb2312//IGNORE" , "0");
$temp['submit_button'] = iconv( "utf-8", "gb2312//IGNORE" , "发布");
$temp['addr'] = iconv( "utf-8", "gb2312//IGNORE" , "bjcanyin");
$temp['ContentBg'] = "";
$temp['newss'] = iconv( "utf-8", "gb2312//IGNORE" , htmlspecialchars_decode("<p>阿会计师的贺卡收到框架</p><p><img alt=\"\" 
src=\" http://localhost/super/Uploads/img/2017-08-10/598c145a9527e.jpg\" style=\"height:243px; width:324px\" /></p>", ENT_QUOTES));
$cookie_file = dirname(__FILE__)."/jdzj.tmp";
$sumbit_url = "http://***/news/***.asp";
$http_url="http://***/news/***.asp";
$img = curl_form($temp,$http_url,$sumbit_url,$cookie_file);
var_dump($img);

PS:关于PHP curl选项详细说明可参考https://www.jb51.net/article/39331.htm

更多关于PHP相关内容感兴趣的读者可查看本站专题:《php curl用法总结》、《PHP网络编程技巧总结》、《PHP数组(Array)操作技巧大全》、《php字符串(string)用法总结》、《PHP数据结构与算法教程》及《PHP中json格式数据操作技巧汇总》

希望本文所述对大家PHP程序设计有所帮助。

广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!