php curl 批量上传,并且带 post 其它表单, 单个上传是可以跟 post 一起,可以批量的话就不行,有什么办法吗?
'foo', 'file'=>$file); //多文件上传为什么不能再传其它post//变成//$data = $file;curl_setopt($ch, curlopt_url, 'http://localhost/upload.php');curl_setopt($ch, curlopt_post, 1);if (class_exists('\curlfile')) { curl_setopt($ch, curlopt_safe_upload, true);} else { if (defined('curlopt_safe_upload')) { curl_setopt($ch, curlopt_safe_upload, false);// 5.6 给改成 true了, 弄回去 }} curl_setopt($ch, curlopt_postfields,$data);curl_exec($ch);//关闭curl资源,并且释放系统资源curl_close($ch);?>
最后运行的结果如何能象表单那样,又有 $_files 又有 $_post 呢?
单文件是可以的,可是多文件就是不行,怎么办?
回复内容: php curl 批量上传,并且带 post 其它表单, 单个上传是可以跟 post 一起,可以批量的话就不行,有什么办法吗?
'foo', 'file'=>$file); //多文件上传为什么不能再传其它post//变成//$data = $file;curl_setopt($ch, curlopt_url, 'http://localhost/upload.php');curl_setopt($ch, curlopt_post, 1);if (class_exists('\curlfile')) { curl_setopt($ch, curlopt_safe_upload, true);} else { if (defined('curlopt_safe_upload')) { curl_setopt($ch, curlopt_safe_upload, false);// 5.6 给改成 true了, 弄回去 }} curl_setopt($ch, curlopt_postfields,$data);curl_exec($ch);//关闭curl资源,并且释放系统资源curl_close($ch);?>
最后运行的结果如何能象表单那样,又有 $_files 又有 $_post 呢?
单文件是可以的,可是多文件就是不行,怎么办?
我记得是必须给个文件名吧。不能传递数组过去。只能指定key。
$postfileds = [ 'file1' => curlfile(xxxxx 'file2' => curlfile(xxxxxxx # 一定要用数组那也一定要这么写 'file[]' => curlfile(xxxxxx 'file[]' => curlfile(xxxxx];
把file_path设置成一个数组 循环执行