PHP  
 PHP_HEAD
downloads | QA | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
 

Test Failure Report for ext/curl/tests/curl_file_upload.phpt ('CURL file uploading')

Script

1: <?php
2:
3:
function testcurl($ch$name$mime ''$postname '')
4: {
5:     if(!empty(
$postname)) {
6:         
$file = new CurlFile($name$mime$postname);
7:     } else if(!empty(
$mime)) {
8:         
$file = new CurlFile($name$mime);
9:     } else {
10:         
$file = new CurlFile($name);
11:     }
12:     
curl_setopt($chCURLOPT_POSTFIELDS, array("file" => $file));
13:     
var_dump(curl_exec($ch));
14: }
15:
16:
$host getenv('PHP_CURL_HTTP_REMOTE_SERVER');
17:
$ch curl_init();
18:
curl_setopt($chCURLOPT_URL"{$host}/get.php?test=file");
19:
curl_setopt($chCURLOPT_RETURNTRANSFER1);
20:
21:
testcurl($ch__DIR__ '/curl_testdata1.txt');
22:
testcurl($ch__DIR__ '/curl_testdata1.txt''text/plain');
23:
testcurl($ch__DIR__ '/curl_testdata1.txt''''foo.txt');
24:
testcurl($ch__DIR__ '/curl_testdata1.txt''text/plain''foo.txt');
25:
26:
$file = new CurlFile(__DIR__ '/curl_testdata1.txt');
27:
$file->setMimeType('text/plain');
28:
var_dump($file->getMimeType());
29:
var_dump($file->getFilename());
30:
curl_setopt($chCURLOPT_POSTFIELDS, array("file" => $file));
31:
var_dump(curl_exec($ch));
32:
33:
$file curl_file_create(__DIR__ '/curl_testdata1.txt');
34:
$file->setPostFilename('foo.txt');
35:
var_dump($file->getPostFilename());
36:
curl_setopt($chCURLOPT_POSTFIELDS, array("file" => $file));
37:
var_dump(curl_exec($ch));
38:
39:
$params = array('file' => '@' __DIR__ '/curl_testdata1.txt');
40:
curl_setopt($chCURLOPT_POSTFIELDS$params);
41:
var_dump(curl_exec($ch));
42:
43:
curl_setopt($chCURLOPT_SAFE_UPLOADtrue);
44:
$params = array('file' => '@' __DIR__ '/curl_testdata1.txt');
45:
curl_setopt($chCURLOPT_POSTFIELDS$params);
46:
var_dump(curl_exec($ch));
47:
48:
curl_setopt($chCURLOPT_URL"{$host}/get.php?test=post");
49:
$params = array('file' => '@' __DIR__ '/curl_testdata1.txt');
50:
curl_setopt($chCURLOPT_POSTFIELDS$params);
51:
var_dump(curl_exec($ch));
52:
53:
curl_close($ch);
54:
?>
55:

Expected

string(%d) "curl_testdata1.txt|application/octet-stream"
string(%d) "curl_testdata1.txt|text/plain"
string(%d) "foo.txt|application/octet-stream"
string(%d) "foo.txt|text/plain"
string(%d) "text/plain"
string(%d) "%s/curl_testdata1.txt"
string(%d) "curl_testdata1.txt|text/plain"
string(%d) "foo.txt"
string(%d) "foo.txt|application/octet-stream"

Deprecated: curl_setopt(): The usage of the @filename API for file uploading is deprecated. Please use the CURLFile class instead in %s on line %d
string(%d) "curl_testdata1.txt|application/octet-stream"
string(0) ""
string(%d) "array(1) {
  ["file"]=>
  string(%d) "@%s/curl_testdata1.txt"
}
"

Output

string(43) "curl_testdata1.txt|application/octet-stream"
string(29) "curl_testdata1.txt|text/plain"
string(32) "foo.txt|application/octet-stream"
string(18) "foo.txt|text/plain"
string(10) "text/plain"
string(56) "/var/php_gcov/PHP_HEAD/ext/curl/tests/curl_testdata1.txt"
string(29) "curl_testdata1.txt|text/plain"
string(7) "foo.txt"
string(32) "foo.txt|application/octet-stream"
string(0) ""
string(0) ""
string(99) "array(1) {
  ["file"]=>
  string(57) "@/var/php_gcov/PHP_HEAD/ext/curl/tests/curl_testdata1.txt"
}
"

Diff

010+ string(0) ""
010- 
011- Deprecated: curl_setopt(): The usage of the @filename API for file uploading is deprecated. Please use the CURLFile class instead in %s on line %d
012- string(%d) "curl_testdata1.txt|application/octet-stream"

 

Generated at Wed, 16 Apr 2014 12:48:04 +0000 (2 days ago)

Copyright © 2005-2014 The PHP Group
All rights reserved.