Answer the question
In order to leave comments, you need to log in
How to send a file using curl?
It's strange that uploadpost.php prints the $_POST superglobal: "Array ( [file_box] => @C:/server/images/1.png)"
And the $_FILES superglobal: "array()"
What's the problem?
$post = array(
"file_box" => "@C:/server/images/1.png"
);
$ch = curl_init();
// сообщаем куда будет отправлять
curl_setopt($ch, CURLOPT_URL, 'http://test.loc/test/uploadpost.php' );
// файлы и данные будет отправлены
curl_setopt($ch, CURLOPT_POSTFIELDS, $post );
// передаем true или 1 если хотим ждать ответа после запроса
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// включим отладочную информацию
curl_setopt($ch, CURLOPT_VERBOSE, true);
$response = curl_exec( $ch );
echo $response;
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question