curl http post 数据和图片
来源:互联网 发布:网络域名买卖 编辑:程序博客网 时间:2024/04/30 10:21
curl http post 数据和图片
2010-11-17 14:47
add_post_tips($url,$port=80,$content,$upload_arr){
$boundray = time();
$h = array();
$m_line="\r\n";
//准备头和XML文档
$h[] = "Content-Type: multipart/form-data; boundary=".$boundray;
$h[] = "Connection: Keep-Alive";
$t = array();
$t[] = "--".$boundray;
$t[] = "Content-Disposition: form-data; name=\"UPLOAD_IDENTIFIER\"".$m_line;
$t[] = "34f4eec9d2922ab59d23c8b02291dd4f";
$t[] = "--".$boundray;
$t[] = "Content-Disposition: form-data; name=\"json\"".$m_line;
$t[] = $content;
$t[] = "--".$boundray;
$t[] = "Content-Disposition: form-data; name=\"File_1\"; filename=\"".$upload_arr['name']."\"";
$t[] = "Content-Type: image/jpeg".$m_line.$m_line;
$c = implode($m_line,$t);
//准备二进制内容
$upload_fp = fopen($upload_arr['tmp_name'], "rb");
while(!feof($upload_fp)) {
$file_piece = fread($upload_fp, 4096);
$c .= $file_piece;
}
fclose($upload_fp);
$c .=$m_line."--".$boundray;
// create a new cURL resource
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_PORT, $port);
curl_setopt($ch, CURLOPT_HTTPHEADER, $h);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $c);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$rsp = curl_exec($ch);
return ($rsp);
}
$boundray = time();
$h = array();
$m_line="\r\n";
//准备头和XML文档
$h[] = "Content-Type: multipart/form-data; boundary=".$boundray;
$h[] = "Connection: Keep-Alive";
$t = array();
$t[] = "--".$boundray;
$t[] = "Content-Disposition: form-data; name=\"UPLOAD_IDENTIFIER\"".$m_line;
$t[] = "34f4eec9d2922ab59d23c8b02291dd4f";
$t[] = "--".$boundray;
$t[] = "Content-Disposition: form-data; name=\"json\"".$m_line;
$t[] = $content;
$t[] = "--".$boundray;
$t[] = "Content-Disposition: form-data; name=\"File_1\"; filename=\"".$upload_arr['name']."\"";
$t[] = "Content-Type: image/jpeg".$m_line.$m_line;
$c = implode($m_line,$t);
//准备二进制内容
$upload_fp = fopen($upload_arr['tmp_name'], "rb");
while(!feof($upload_fp)) {
$file_piece = fread($upload_fp, 4096);
$c .= $file_piece;
}
fclose($upload_fp);
$c .=$m_line."--".$boundray;
// create a new cURL resource
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_PORT, $port);
curl_setopt($ch, CURLOPT_HTTPHEADER, $h);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $c);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$rsp = curl_exec($ch);
return ($rsp);
}
- curl http post 数据和图片
- php cUrl 通过 http post json数据
- PHP使用CURL向服务器POST文本数据和上传图片的代码示例
- http模拟post提交数据(三),curl方式
- CURL POST 数据
- php http post 方式有curl 、 file_get_content 、 fsocket ,来post提交数据
- CURL POST请求上传图片
- PHP POST CURL上传图片
- perl和curl 模拟post 发送json数据
- CURL POST大数据和lighttpd出现的…
- 使用curl命令post数据
- curl get post 请求数据
- cURL模拟POST提交数据
- curl get post 获取数据
- curl 拼装参数post数据
- curl模拟post提交数据
- php通过curl post和get发送json数据实例 curl命令转为php源码
- 模拟http 提示数据 POST 和 GET
- 设计中最困难的部分是决定设计什么
- Ext 组件操作总结——会不断完善
- 发邮件和收邮件
- CentOS终端乱码
- ExtJs源码分析与学习—ExtJs事件机制(一)
- curl http post 数据和图片
- Delphi clientdataset的详细介绍
- ExtJs源码分析与学习—ExtJs事件机制(二)
- WebKit中自定义JavaScript类型对instanceof语句的处理
- linux mysql乱码解决
- 2011年7月27日
- php 字符串、文件转化成二进制流文件
- ExtJs源码分析与学习—ExtJs事件机制(三)
- 浅析setsockopt