1--TEST--
2curl_copy_handle() allows to post CURLFile multiple times if postfields change
3--EXTENSIONS--
4curl
5--FILE--
6<?php
7include 'server.inc';
8$host = curl_cli_server_start();
9
10$ch1 = curl_init();
11curl_setopt($ch1, CURLOPT_SAFE_UPLOAD, 1);
12curl_setopt($ch1, CURLOPT_URL, "{$host}/get.php?test=file");
13curl_setopt($ch1, CURLOPT_RETURNTRANSFER, 1);
14
15$filename = __DIR__ . '/abc.txt';
16file_put_contents($filename, "Test.");
17$file = curl_file_create($filename);
18$params = array('file' => $file);
19var_dump(curl_setopt($ch1, CURLOPT_POSTFIELDS, $params));
20
21$ch2 = curl_copy_handle($ch1);
22
23$filename = __DIR__ . '/def.txt';
24file_put_contents($filename, "Other test.");
25$file = curl_file_create($filename);
26$params = array('file' => $file);
27var_dump(curl_setopt($ch2, CURLOPT_POSTFIELDS, $params));
28
29$ch3 = curl_copy_handle($ch2);
30
31var_dump(curl_exec($ch1));
32curl_close($ch1);
33
34var_dump(curl_exec($ch2));
35curl_close($ch2);
36
37var_dump(curl_exec($ch3));
38curl_close($ch3);
39?>
40===DONE===
41--EXPECTF--
42bool(true)
43bool(true)
44string(%d) "abc.txt|application/octet-stream|5"
45string(%d) "def.txt|application/octet-stream|11"
46string(%d) "def.txt|application/octet-stream|11"
47===DONE===
48--CLEAN--
49<?php
50@unlink(__DIR__ . '/abc.txt');
51@unlink(__DIR__ . '/def.txt');
52?>
53