Skip to content

Commit 7f66973

Browse files
committed
Fix php-curl-class#384: Add multi curl file upload example
1 parent ae6a3e5 commit 7f66973

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

examples/multi_curl_upload_file.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
require __DIR__ . '/vendor/autoload.php';
3+
4+
use \Curl\MultiCurl;
5+
6+
$multi_curl = new MultiCurl();
7+
8+
// HINT: If API documentation refers to using something like curl -F "myimage=image.png",
9+
// curl --form "myimage=image.png", or the html form is similar to <form enctype="multipart/form-data" method="post">,
10+
// then try uncommenting the following line:
11+
// $multi_curl->setHeader('Content-Type', 'multipart/form-data');
12+
13+
$multi_curl->addPost('https://httpbin.org/post', array(
14+
'image' => new CURLFile('the-lorax.jpg'),
15+
));
16+
17+
$multi_curl->addPost('https://httpbin.org/post', array(
18+
'image' => new CURLFile('swomee-swans.jpg'),
19+
));
20+
21+
$multi_curl->addPost('https://httpbin.org/post', array(
22+
'image' => new CURLFile('truffula-trees.jpg'),
23+
));
24+
25+
$multi_curl->start();

0 commit comments

Comments
 (0)