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

curl-and-php

File uploading plus multiple values for the same key

From: Beau Simensen <simensen_at_gmail.com>
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
file.

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
http://suite100gallery.com/
Halogen Creative LLC
http://halogencreative.com/
s3a - Fresh. Urban. Seattle.
http://s3a.us/
[blog] http://not-invented-here.com/
[flickr] http://beausimensen.com/#flickr
[facebook] http://beausimensen.com/#facebook

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2008-12-27