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
12list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS);
13$port = intval($port)?:80;
14
15$fp = fsockopen($host, $port, $errno, $errstr, 0.5);
16if (!$fp) {
17  die("connect failed");
18}
19
20$post_data = <<<POST
21-----------------------------114782935826962
22Content-Disposition: form-data; name="userfile"; filename="laruence.txt"
23Content-Type: text/plain
24
25I am not sure about this.
26
27-----------------------------114782935826962--
28
29
30POST;
31
32$post_len = strlen($post_data);
33
34if(fwrite($fp, <<<HEADER
35POST / HTTP/1.1
36Host: {$host}
37Content-Type: multipart/form-data; boundary=---------------------------114782935826962
38Content-Length: {$post_len}
39
40
41{$post_data}
42HEADER
43)) {
44	while (!feof($fp)) {
45		echo fgets($fp);
46	}
47}
48
49?>
50--EXPECTF--
51HTTP/1.1 200 OK
52Host: %s
53Date: %s
54Connection: close
55X-Powered-By: PHP/%s
56Content-type: text/html; charset=UTF-8
57
58array(1) {
59  ["userfile"]=>
60  array(5) {
61    ["name"]=>
62    string(12) "laruence.txt"
63    ["type"]=>
64    string(10) "text/plain"
65    ["tmp_name"]=>
66    string(%d) "%s"
67    ["error"]=>
68    int(0)
69    ["size"]=>
70    int(26)
71  }
72}
73