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

curl-and-php

Hi + Multipart/Post question

From: Simon Yorkston <simon_at_ice.org>
Date: Thu, 03 Nov 2005 19:38:42 +1000

Hi guys.
I've been tearing my hair out, so I thought I'd try for some assistance.

Scenario:
Automating form data & a file upload (image) to a remote server.

In the original form on the remote server, they have a series of
checkboxes, named 'category[1][]' - for PHP to pickup and convert to
arrays on the other side.
Therein lies the problem - I can't send the same fieldname more than
once- so to try to mimic it, I can go (cropped down just to the
important part)

curl_setopt($ch, CURLOPT_POSTFIELDS,
"category[1][]=orange&category[1][]=blue&category[1][]=green");

But I can't include the file in that string. I tried with &file=@file,
and @file=file_get_contents($uploadedFile); - neither of which work

Alternatively, I can try
$this->post['file'] = @$filename;
$this->post['category[1][]'] = 'red';
$this->post['category[1][]'] = 'blue';
$this->post['category[1][]'] = 'yellow';
curl_setopt($ch, CURLOPT_POSTFIELDS, $this->post);

Which will upload the file, and set category to 'yellow' - but obviously
not all three.

Finally, I tried doing a mixture

$this->post['file'] = @$filename;
curl_setopt($ch, CURLOPT_POSTFIELDS,
"category[1][]=orange&category[1][]=blue&category[1][]=green");
curl_setopt($ch, CURLOPT_POSTFIELDS, $this->post);

Which didn't work, either.

Anyone have any ideas?
I'm stumped!

Thanks,
Simon

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2005-11-03