Skip to content

cURL - Send 2+ files using the same parameter name ("file[]") #15859

Description

@ghnp5

Description

The pull request #8292 made it possible to send an array of parameters of the same name.

However, it doesn't seem to support files:

I'm using PHP 8.3, but I'm not succeeding in doing this:

curl_setopt($ch, CURLOPT_HTTPHEADER, [
	'Content-Type: multipart/form-data'
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, [
	'file' => [
		new CURLFile($file1, posted_filename: 'File1.jpg'),
		new CURLFile($file2, posted_filename: 'File2.jpg')
	]
]);

PHP Fatal error: Uncaught Error: Object of class CURLFile could not be converted to string

Would it be possible to fix this, please?

Thank you very much!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions