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

curl-and-php

libcurl, PHP, HTML forms, and an array of values

From: Thomas Tremain <thomas_at_tremaininc.com>
Date: Fri, 3 Sep 2010 03:25:59 -0700

I am trying to use cURL to post to a form, that uses an array of values,
like:

<input type="hidden" name="MAX_FILE_SIZE" value="1000000">
<input type="file" name="photo[]">
<input type="file" name="photo[]">
<input type="file" name="photo[]">

or:
<SELECT name="img_gallery[]" SIZE=3 MULTIPLE>
<OPTION VALUE="16869.jpg"> - 16869.jpg
<OPTION VALUE="16864.jpg"> - 16864.jpg
</SELECT>

All other POSTvars seem to work fine.

 

 

 

 

 $posts=array('photo'=>"@bp10-02-01.jpeg",
    'img_gallery'=>'168649mojave1.jpg');

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$URL);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$posts);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_REFERER, $reffer);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$result = curl_exec ($ch);
curl_close ($ch);
echo '----------------------<br>';
echo("Results: <br>".$result);

 

The files never get uploaded, because they are supposed to be in an array.
Yet putting them in an array doesn't seem to help.

 

 

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