相思资源网 Design By www.200059.com

本文实例讲述了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程序设计有所帮助。

标签:
PHP,CURL,模拟登陆,上传文件

相思资源网 Design By www.200059.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
相思资源网 Design By www.200059.com

评论“PHP CURL实现模拟登陆并上传文件操作示例”

暂无PHP CURL实现模拟登陆并上传文件操作示例的评论...