xref: /PHP-5.6/ext/curl/tests/bug27023.phpt (revision c507c9f0)
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
7include 'skipif.inc';
8?>
9--FILE--
10<?php
11
12  include 'server.inc';
13  $host = curl_cli_server_start();
14$ch = curl_init();
15curl_setopt($ch, CURLOPT_SAFE_UPLOAD, 0);
16curl_setopt($ch, CURLOPT_URL, "{$host}/get.php?test=file");
17curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
18
19$params = array('file' => '@' . __DIR__ . '/curl_testdata1.txt');
20curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
21var_dump(curl_exec($ch));
22
23$params = array('file' => '@' . __DIR__ . '/curl_testdata1.txt;type=text/plain');
24curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
25var_dump(curl_exec($ch));
26
27$params = array('file' => '@' . __DIR__ . '/curl_testdata1.txt;filename=foo.txt');
28curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
29var_dump(curl_exec($ch));
30
31$params = array('file' => '@' . __DIR__ . '/curl_testdata1.txt;type=text/plain;filename=foo.txt');
32curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
33var_dump(curl_exec($ch));
34
35$params = array('file' => '@' . __DIR__ . '/curl_testdata1.txt;filename=foo.txt;type=text/plain');
36curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
37var_dump(curl_exec($ch));
38
39
40curl_close($ch);
41?>
42--EXPECTF--
43string(%d) "curl_testdata1.txt|application/octet-stream"
44string(%d) "curl_testdata1.txt|text/plain"
45string(%d) "foo.txt|application/octet-stream"
46string(%d) "foo.txt|text/plain"
47string(%d) "foo.txt|text/plain"
48