Skip to content

Commit e742f0e

Browse files
author
XieBiao
committed
support upload file
1 parent 1b3ef89 commit e742f0e

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

examples/olddriver.gif

1.41 MB
Loading

examples/uploadfile.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
require '../vendor/autoload.php';
3+
4+
use Hhxsv5\PhpMultiCurl\Curl;
5+
6+
$postUrl = 'http://localhost/upload.php';//<?php var_dump($_FILES);
7+
8+
$options = [//The custom the curl options
9+
CURLOPT_TIMEOUT => 10,
10+
CURLOPT_CONNECTTIMEOUT => 5,
11+
CURLOPT_USERAGENT => 'Multi-Curl Client V1.0',
12+
];
13+
$c1 = new Curl($options);
14+
15+
$file1 = new CURLFile('./olddriver.gif', 'image/gif', 'name1');
16+
$params = ['file1' => $file1];
17+
$c1->makePost($postUrl, $params);
18+
$ret = $c1->exec();
19+
var_dump($ret);
20+
if ($ret) {
21+
//Success
22+
var_dump($c1->getResponse());
23+
} else {
24+
//Fail
25+
var_dump($c1->getError());
26+
}

0 commit comments

Comments
 (0)