[PHP]curl上传多文件
码一下curl上传多文件的行
5.5之前版本的写法
$file = array(
'pic[0]'=>"@E:\\wwwroot\\10003\\temp_56.ini;type=text/html;filename=temp_56.ini",
'pic[1]'=>"@E:\\wwwroot\\10003\\temp_29.html;type=text/html;filename=temp_29.html"
);
5.5以上版本的写法
php 5.5 version or above
$file = array(
'pic[0]'=>new CURLFile('E:\\wwwroot\\10003\\temp_56.ini', 'text/html', 'temp_56.ini'),
'pic[1]'=>new CURLFile('E:\\wwwroot\\10003\\temp_29.html', 'text/html', 'temp_29.html')
);
合并其他的POST参数,POST出去
$data = array_merge($file, $data);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true );
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// curl_getinfo($ch);
$return_data = curl_exec($ch);
curl_close($ch);
echo $return_data;
[PHP]curl上传多文件的更多相关文章
- PHP使用CURL上传|下载文件
CURL下载文件 /** * @param string $img_url 下载文件地址 * @param string $save_path 下载文件保存目录 * @param string $fi ...
- PHP如何通过CURL上传文件
PHP使用CURL上传文件只需发送一个POST请求就可以了,在请求中设置某个字段为需要上传的文件全路径,并且以“@”开头,然后使用CURL把该变量以POST方式发送到服务器,在服务端即可以从超级全局变 ...
- CURL 和LIBCURL C++代码 上传本地文件,好不容易碰到了这种折腾我几天的代码
解决了什么问题:curl在使用各种方式上传文件到服务器.一般的文件上传是通过html表单进行的,通过CURL可以不经过浏览器,直接在服务器端模拟进行表单提交,完成POST数据.文件上传等功能. 服务器 ...
- linux使用curl上传文件并且同时携带其它传递参数
一般使用linux原生态的命令curl上传文件时命令如下 假如要上传文件是myfile.txt curl -F "file_name=@myfile.txt" -X POST &q ...
- curl 上传文件
1)在 php 5.5.0 之前,如果使用 @+文件路径的文件上传文件,具体看这里:http://www.cnblogs.com/tujia/p/5938463.html 2)php 5.5.0 之后 ...
- php curl上传文件$_FILES为空问题
php使用curl上传文件,代码如下: 发送的代码(完全是官方的示例) <?php /* http://localhost/upload.php:print_r($_POST);print_r( ...
- PHP 5.6 如何使用 CURL 上传文件
以前我们通过 PHP 的 cURL 上传文件是,是使用“@+文件全路径”的来实现的: curl_setopt(ch, CURLOPT_POSTFIELDS, array( 'file' => ' ...
- PHP 5.5以上 使用 CURL 上传文件
PHP 5.5以上 使用 CURL 上传文件的代码: curl_setopt(ch, CURLOPT_POSTFIELDS, [ 'file' => new CURLFile(realpath( ...
- 使用curl 上传文件,multipart/form-data
使用curl 上传文件,multipart/form-data 1. 不使用-F,curl内置multipart/form-data功能: 2. 文件内容与真实数据无关,用abc代替数据,依然可以上传 ...
随机推荐
- thinkcmf 相关
后台登录,暂停关掉登录验证码: /Volumes/macHD2/myCode/wwwroot/app/admin/controller/PublicController.php $captcha = ...
- sql server中的merge
http://www.cnblogs.com/CareySon/archive/2012/03/07/2383690.html 简介 Merge关键字是一个神奇的DML关键字.它在SQL Server ...
- springboot11-01-security入门
场景: 有3个页面:首页.登录页.登录成功后的主页面,如下图: 如果没有登录,点击“去主页”,会跳转到登录页 如果已经登录,点击“去主页”,跳转到主页,显示“hello 用户名” 下面用springb ...
- Python 获取文件中最长行的长度和最长行
1, 使用文件 #vim /etc/motd "1 hello world" 2 ...... yes 3 no you are a shadiao 4 hahh maye you ...
- python之MD5加密
一. MD5加密import hashlib #Python3里的引用#import md5 #Python2里的引用 1. md5是不可逆的,不能解密2. 所有语言生成的md5串都是一样的 3. 不 ...
- Python 9 进程,线程
本节内容 python GIL全局解释器锁 线程 进程 Python GIL(Global Interpreter Lock) In CPython, the global interpreter l ...
- 02、natapp的使用
使用方法 官网: https://natapp.cn 命令启动:natapp -authtoken=***************** 文档:https://natapp.cn/article/nat ...
- 🌵react小记 🌵
- mongodb系列~mongodb集群介绍与管理
mongodb 集群维护1 简介 谈谈mongodb的集群架构2 常用的维护命令 1 查看状态 sh.status() 1 version 2 shards: ...
- python读取两个文件并且判断是否一致
''' 判断两个文件是否相同,如果不同请指出第几行不相同 ''' def f1vsf2(name1,name2): f1 = open(name1) f2 = open(name2) count = ...