note 66678 added to function.curl-setopt

From: Date: Thu, 25 May 2006 20:08:29 +0000
Subject: note 66678 added to function.curl-setopt
Groups: php.notes 
Request: Send a blank email to php-notes+get-112283@lists.php.net to get a copy of this message
Passing a <select multiple> through CURLOPT_POSTFIELDS is pretty unintuitive. Try this: <? curl_setopt(CURLOPT_POSTFIELDS, "a=value1&a=value2&a=value3"); ?> That works great, until you need to do something like pass a file through POST, too. After combing the Web for hours, I found that this works: <? curl_setopt(CURLOPT_POSTFIELDS, array( "a[0]" => "value1", "a[1]" => "value2", "a[2]" => "value3", ... "myfile" => "@file.txt" )); ?> This worked as long as I was passing to other PHP scripts. Perl and other languages don't like the parameter[] trick, and while passing to one, I had to use a combination of GET and POST. Caveat emptor. ---- Server IP: 216.194.113.175 Probable Submitter: 128.59.100.63 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.curl-setopt.php Edit -- http://master.php.net/note/edit/66678 Del: integrated -- http://master.php.net/note/delete/66678/integrated Del: useless -- http://master.php.net/note/delete/66678/useless Del: bad code -- http://master.php.net/note/delete/66678/bad+code Del: spam -- http://master.php.net/note/delete/66678/spam Del: non-english -- http://master.php.net/note/delete/66678/non-english Del: in docs -- http://master.php.net/note/delete/66678/in+docs Del: other reasons-- http://master.php.net/note/delete/66678 Reject -- http://master.php.net/note/reject/66678 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#112283) next »