php multiple file upload to another server curl

Solutions on MaxInterview for php multiple file upload to another server curl by the best coders in the world

showing results for - "php multiple file upload to another server curl"
Leah
12 Jul 2020
1<?php
2
3$user = "admin";
4
5$postField = array();
6
7$postFields['user'] = $user; //postdata
8
9$postFields['upload_file'] = array(
10
11        'file[0]' => '@' . realpath('first-file.jpg'),
12        'file[1]' => '@' . realpath('second-file.jpg')
13    )
14
15$headers = array("Content-Type" => "multipart/form-data");
16$curl_handle = curl_init();
17curl_setopt($curl_handle, CURLOPT_URL, "http://serverdomain.com/upload/uploadMultipleFiles");
18curl_setopt($curl_handle, CURLOPT_HTTPHEADER, $headers);
19curl_setopt($curl_handle, CURLOPT_POST, TRUE);
20curl_setopt($curl_handle, CURLOPT_POSTFIELDS, $postFields);
21curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, TRUE);
22
23$returned_data = curl_exec($curl_handle);
24curl_close($curl_handle);
25echo $returned_data ;