curl-and-php
Re: libcurl, PHP, HTML forms, and an array of values
Date: Fri, 03 Sep 2010 16:35:58 -0400
On 9/3/10 6:25 AM, "Thomas Tremain" <thomas_at_Tremaininc.com> wrote:
> 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.
perhaps the files never get uploaded because their full paths were not
given:
"To post a file, prepend a filename with @ and use the full path."
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2010-09-03