I have problem with curl file upload using PHP when form name of input file is an integer: <input type="file" name="1">
I have following array that I put in CURLOPT_POSTFIELDS to get multipart/form-data:
$array = array(
"MAX_FILE_SIZE" => 80000,
"1" => '@'.$cfg['lpath'].'logos/'.domain($projekt['adres']).'.jpg;type=image/jpeg',
"2" => '@'.($cfg['lpath']==''?'/dev/null':'NUL:').';filename=',
"3" => '@'.($cfg['lpath']==''?'/dev/null':'NUL:').';filename=',
"send" => 'send it'
);
I send it to server and var_dump($_POST, $_FILES) is as follow:
$_POST:
array(2) {
["MAX_FILE_SIZE"]=>
string(5) "80000"
["send"]=>
string(7) "send it"
}
$_FILES:
array(1) {
["MAX_FILE_SIZE"]=>
array(5) {
["name"]=>
string(0) ""
["type"]=>
string(0) ""
["tmp_name"]=>
string(0) ""
["error"]=>
int(4)
["size"]=>
int(0)
}
}
When I change array keys to letters it works as expected:
$_FILES:
array(3) {
["a"]=>
array(5) {
["name"]=>
string(16) "filename.jpg"
["type"]=>
string(10) "image/jpeg"
["tmp_name"]=>
string(14) "/tmp/phpRZMiRA"
["error"]=>
int(0)
["size"]=>
int(6567)
}
["b"]=>
array(5) {
["name"]=>
string(0) ""
["type"]=>
string(0) ""
["tmp_name"]=>
string(0) ""
["error"]=>
int(4)
["size"]=>
int(0)
}
["c"]=>
array(5) {
["name"]=>
string(0) ""
["type"]=>
string(0) ""
["tmp_name"]=>
string(0) ""
["error"]=>
int(4)
["size"]=>
int(0)
}
}
Is it a bug? Is it possible to send such an array using curl?
My PHP Version is 5.3.25 Curl version 7.30.0