1--TEST-- 2Bug #27023 (CURLOPT_POSTFIELDS does not parse content types for files) 3--SKIPIF-- 4<?php 5if (!extension_loaded("curl")) { 6 exit("skip curl extension not loaded"); 7} 8if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) { 9 exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined"); 10} 11?> 12--FILE-- 13<?php 14 15$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); 16$ch = curl_init(); 17curl_setopt($ch, CURLOPT_URL, "{$host}/get.php?test=file"); 18curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 19 20$params = array('file' => '@' . __DIR__ . '/curl_testdata1.txt'); 21curl_setopt($ch, CURLOPT_POSTFIELDS, $params); 22var_dump(curl_exec($ch)); 23 24$params = array('file' => '@' . __DIR__ . '/curl_testdata1.txt;type=text/plain'); 25curl_setopt($ch, CURLOPT_POSTFIELDS, $params); 26var_dump(curl_exec($ch)); 27 28$params = array('file' => '@' . __DIR__ . '/curl_testdata1.txt;filename=foo.txt'); 29curl_setopt($ch, CURLOPT_POSTFIELDS, $params); 30var_dump(curl_exec($ch)); 31 32$params = array('file' => '@' . __DIR__ . '/curl_testdata1.txt;type=text/plain;filename=foo.txt'); 33curl_setopt($ch, CURLOPT_POSTFIELDS, $params); 34var_dump(curl_exec($ch)); 35 36$params = array('file' => '@' . __DIR__ . '/curl_testdata1.txt;filename=foo.txt;type=text/plain'); 37curl_setopt($ch, CURLOPT_POSTFIELDS, $params); 38var_dump(curl_exec($ch)); 39 40 41curl_close($ch); 42?> 43--EXPECTF-- 44string(%d) "curl_testdata1.txt|application/octet-stream" 45string(%d) "curl_testdata1.txt|text/plain" 46string(%d) "foo.txt|application/octet-stream" 47string(%d) "foo.txt|text/plain" 48string(%d) "foo.txt|text/plain" 49