1--TEST-- 2file upload greater than 2G 3--SKIPIF-- 4<?php 5include "skipif.inc"; 6 7if (PHP_INT_SIZE < 8) { 8 die("skip need PHP_INT_SIZE>=8"); 9} 10 11if (!file_exists('/proc/meminfo')) { 12 die('skip Cannot check free RAM from /proc/meminfo on this platform'); 13} 14 15$free_ram = 0; 16if ($f = fopen("/proc/meminfo","r")) { 17 while (!feof($f)) { 18 if (preg_match('/MemFree[^\d]*(\d+)/i', fgets($f), $m)) { 19 $free_ram = max($free_ram, $m[1]/1024/1024); 20 if ($free_ram > 3) { 21 $enough_free_ram = true; 22 } 23 } 24 } 25} 26 27if (empty($enough_free_ram)) { 28 die(sprintf("skip need +3G free RAM, but only %01.2f available", $free_ram)); 29} 30 31if (getenv('TRAVIS')) { 32 die("skip Fails intermittently on travis"); 33} 34 35if (getenv('SKIP_PERF_SENSITIVE')) { 36 die("skip Test may be very slow if PHP is instrumented"); 37} 38?> 39--FILE-- 40<?php 41 42echo "Test\n"; 43 44include "php_cli_server.inc"; 45 46php_cli_server_start("var_dump(\$_FILES);", null, 47 ["-d", "post_max_size=3G", "-d", "upload_max_filesize=3G"]); 48 49$length = 2150000000; 50$output = ""; 51 52$host = PHP_CLI_SERVER_HOSTNAME; 53$fp = php_cli_server_connect(); 54 55$prev = "----123 56Content-Type: text/plain; charset=UTF-8 57Content-Disposition: form-data; name=\"file1\"; filename=\"file1.txt\"\n\n"; 58$post = "\n----123--\n"; 59$total = $length + strlen($prev) + strlen($post); 60 61fwrite($fp, <<<EOF 62POST /index.php HTTP/1.1 63Host: {$host} 64Content-Type: multipart/form-data; boundary=--123 65Content-Length: {$total} 66 67{$prev} 68EOF 69) or die("write prev failed"); 70 71$data = str_repeat("0123456789", 10000); 72for ($i = 0; $i < $length; $i += 10000 * 10) { 73 fwrite($fp, $data) or die("write failed @ ($i)"); 74} 75 76fwrite($fp, $post) or die("write post failed"); 77 78while (!feof($fp)) { 79 $output .= fgets($fp); 80} 81echo $output; 82fclose($fp); 83?> 84Done 85--EXPECTF-- 86Test 87HTTP/1.1 200 OK 88Host: %s 89Date: %s 90Connection: close 91X-Powered-By: PHP/%s 92Content-type: text/html; charset=UTF-8 93 94array(1) { 95 ["file1"]=> 96 array(5) { 97 ["name"]=> 98 string(9) "file1.txt" 99 ["type"]=> 100 string(10) "text/plain" 101 ["tmp_name"]=> 102 string(%d) "%s" 103 ["error"]=> 104 int(0) 105 ["size"]=> 106 int(2150000000) 107 } 108} 109Done 110