I have a very complicated task here and I need help. Maye somebody could help and has the missing clue.
I need to request a php-form-page with curl (and send cookies). All of this is fine and works. But the form page search for a $_FILE['picture'] and can't find it.
I tried it before with a simple empty 'picture' name and also with 'picture' => '@'.
I can send a "real" file name from my desk and create a CURL-FILE-object, but I don't want to add a file.
It should be the same, if I have an empty upload form.
I want to get:
$_FILE = Array
(
[bild] => Array
(
[name] =>
[type] =>
[tmp_name] =>
[error] => 4
[size] => 0
)
)
How can I force this with curl if I request the PHP-page?
I tried it with this way: PHP Send local file by cURL and it works. But I don't want to send a file, I will only force the file array to pass the form.
Any ideas? Thank you in advance for helping!
This is the current/last state:
<?php
$ch = curl_init();
$data = array('name' => 'Foo', 'file' => '@');
curl_setopt($ch, CURLOPT_URL, 'http://localhost/testpage.php');
curl_setopt ($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_HTTPHEADER,
array(
'Content-Type: multipart/form-data'
)
);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_exec($ch);
curl_close($ch);
?>
And results only:
$_POST: Array
(
[name] => Foo
[file] => @
)
$_FILES: Array
(
)