note 119578 added to book.curl

From: Date: Mon, 11 Jul 2016 08:37:06 +0000
Subject: note 119578 added to book.curl
Groups: php.notes 
Request: Send a blank email to php-notes+get-205961@lists.php.net to get a copy of this message
If you need to send an array of files using CURL (typical case: POST variable to a REST API), having an array of CURLFiles in the POSTFIELD won't work. You have to set as many variables in your postfield than there are files to send: <?php // Won't work: $postfields = array( 'files' => array( new CURLFile($path1), new CURLFile($path2), //... ) ); curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields); // Use this instead: $postfields = array( 'files[0]' => new CURLFile($path1), 'files[1]' => new CURLFile($path2), //... ); curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields); ?> ---- Server IP: 72.52.91.14 Probable Submitter: 62.96.159.236 ---- Manual Page -- http://php.net/manual/en/book.curl.php Edit -- https://master.php.net/note/edit/119578 Del: integrated -- https://master.php.net/note/delete/119578/integrated Del: useless -- https://master.php.net/note/delete/119578/useless Del: bad code -- https://master.php.net/note/delete/119578/bad+code Del: spam -- https://master.php.net/note/delete/119578/spam Del: non-english -- https://master.php.net/note/delete/119578/non-english Del: in docs -- https://master.php.net/note/delete/119578/in+docs Del: other reasons-- https://master.php.net/note/delete/119578 Reject -- https://master.php.net/note/reject/119578 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#205961) next »