This means you are trying to send the files as mentioned in the below code:
This is what should be the ideal code to send multiple files through php as per the manual, but pragmatically, it isn’t right. You will not be able to send array of files through curl or technically, we can say, it won’t support multi-dimensional arrays. Instead, you can send them as multiple CURL File objects
(PHP 5 >= 5.5.0, PHP 7) or single dimension array if you are using PHP <5.
So the below code would help you send multiple files using CURL File object:
If your version of php doesn’t support CURL File objects, you can declare the array as
$postFields['upload_file_0'] = '@' . realpath('first-file.jpg');//@ is mandatory to send files $postFields['upload_file_1'] = '@' . realpath('first-file.jpg');
In case of more than two files or some ‘n’ number of files you can use loop:
Hope this helped you dig out a perfect solution!