cURL / Mailing Lists / curl-and-php / Single Mail


File uploading plus multiple values for the same key

From: Beau Simensen <>
Date: Sat, 27 Dec 2008 11:06:25 -0800

I want to use curl to upload a file and send multiple values for another key
in the same request. What I am looking for is something like the following:
$postinfo = array(
    'filename' => '@/path/to/file',
    'title' => 'My New File',
    'tag' => array('featured', 'zip', 'games')

Most of the references I've been able to find an the issue of passing an
array for a single key have discussed reverting to the string version
of CURLOPT_POSTFIELDS. While I would almost consider this a valid workaround
for the issue, it will not work for me on account of having to also pass a

I would have a hard time believing there is not a better solution for the
array field issue as this seems to be quite common (checkboxes, multiple
selects, etc.). Is there a way to actually upload the array structure as
I've written it above, or do I actually have to generate the
tag=featured&tag=zip&tag=games string by hand? And if the latter, how do I
get the file included in the same request?

Beau D. Simensen
Suite 100 Gallery
Halogen Creative LLC
s3a - Fresh. Urban. Seattle.

Received on 2008-12-27