note 62274 added to ref.curl
| From: | heyrocker at yahoo dot com | Date: | Thu, 23 Feb 2006 21:57:44 +0000 |
| Subject: | note 62274 added to ref.curl | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-104326@lists.php.net to get a copy of this message | ||
The examples below for HTTP file upload work great, but I wanted to be able to post multiple files
through HTTP upload using HTML arrays as specified in example 38.3 at
http://us3.php.net/features.file-upload
In this case, you need to set the arrays AND keys in the $post_data, it will not work with just the
array names. The following example shows how this works:
<?php
$post_data = array();
$post_data['pictures[0]'] = "@cat.jpg";
$post_data['pictures[1]'] = "@dog.jpg";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://my.domain.com/my_url.php" );
curl_setopt($ch, CURLOPT_POST, 1 );
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$postResult = curl_exec($ch);
if (curl_errno($ch)) {
print curl_error($ch);
}
curl_close($ch);
print "$postResult";
?>
----
Server IP: 216.194.113.175
Probable Submitter: 192.251.219.11
----
Manual Page -- http://www.php.net/manual/en/ref.curl.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+62274
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+62274&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+62274&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+62274&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+62274&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+62274&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+62274&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+62274&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+62274&report=yes
Search -- http://master.php.net/manage/user-notes.php