1--TEST-- 2Bug #27023 (CURLOPT_POSTFIELDS does not parse content types for files) 3--INI-- 4error_reporting = E_ALL & ~E_DEPRECATED 5--SKIPIF-- 6<?php include 'skipif.inc'; ?> 7--FILE-- 8<?php 9 10include 'server.inc'; 11$host = curl_cli_server_start(); 12$ch = curl_init(); 13curl_setopt($ch, CURLOPT_SAFE_UPLOAD, 1); 14curl_setopt($ch, CURLOPT_URL, "{$host}/get.php?test=file"); 15curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 16 17$file = curl_file_create(__DIR__ . '/curl_testdata1.txt'); 18$params = array('file' => $file); 19curl_setopt($ch, CURLOPT_POSTFIELDS, $params); 20var_dump(curl_exec($ch)); 21 22$file = curl_file_create(__DIR__ . '/curl_testdata1.txt', "text/plain"); 23$params = array('file' => $file); 24curl_setopt($ch, CURLOPT_POSTFIELDS, $params); 25var_dump(curl_exec($ch)); 26 27$file = curl_file_create(__DIR__ . '/curl_testdata1.txt', null, "foo.txt"); 28$params = array('file' => $file); 29curl_setopt($ch, CURLOPT_POSTFIELDS, $params); 30var_dump(curl_exec($ch)); 31 32$file = curl_file_create(__DIR__ . '/curl_testdata1.txt', "text/plain", "foo.txt"); 33$params = array('file' => $file); 34curl_setopt($ch, CURLOPT_POSTFIELDS, $params); 35var_dump(curl_exec($ch)); 36 37 38curl_close($ch); 39?> 40--EXPECTF-- 41string(%d) "curl_testdata1.txt|application/octet-stream" 42string(%d) "curl_testdata1.txt|text/plain" 43string(%d) "foo.txt|application/octet-stream" 44string(%d) "foo.txt|text/plain" 45