1--TEST--
2Post a file
3--SKIPIF--
4<?php
5include "skipif.inc";
6?>
7--FILE--
8<?php
9include "php_cli_server.inc";
10php_cli_server_start('var_dump($_FILES);');
11
12$host = PHP_CLI_SERVER_HOSTNAME;
13$fp = php_cli_server_connect();
14
15$post_data = <<<POST
16-----------------------------114782935826962
17Content-Disposition: form-data; name="userfile"; filename="laruence.txt"
18Content-Type: text/plain
19
20I am not sure about this.
21
22-----------------------------114782935826962--
23
24
25POST;
26
27$post_len = strlen($post_data);
28
29if(fwrite($fp, <<<HEADER
30POST / HTTP/1.1
31Host: {$host}
32Content-Type: multipart/form-data; boundary=---------------------------114782935826962
33Content-Length: {$post_len}
34
35
36{$post_data}
37HEADER
38)) {
39    while (!feof($fp)) {
40        echo fgets($fp);
41    }
42}
43
44?>
45--EXPECTF--
46HTTP/1.1 200 OK
47Host: %s
48Date: %s
49Connection: close
50X-Powered-By: PHP/%s
51Content-type: text/html; charset=UTF-8
52
53array(1) {
54  ["userfile"]=>
55  array(5) {
56    ["name"]=>
57    string(12) "laruence.txt"
58    ["type"]=>
59    string(10) "text/plain"
60    ["tmp_name"]=>
61    string(%d) "%s"
62    ["error"]=>
63    int(0)
64    ["size"]=>
65    int(26)
66  }
67}
68