curl多文件上传

发送:

header('Content-type:text/html; charset=utf-8');  //声明编码
//模拟批量POST上传文件
$url = 'http://test.cm/receive.php';
$data = array(
new CURLFile(__DIR__ .'paypal.php'),
new CURLFile(__DIR__ .'pp.php'),
);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
$content = curl_exec($curl);
curl_close($curl);
//print_r($content);
echo $content;

  

接收:

echo json_encode($_FILES);

  

原文地址:https://www.cnblogs.com/huixuexidezhu/p/8513667.html