Answer the question
In order to leave comments, you need to log in
Why doesn't sending a file to cUrl work?
I'm trying to send a file via cUrl, but the transferred data is not perceived as $_FILES, but as plain text.
There is index.php and post.php
index.php
$post = [
'image' => "@/Library/WebServer/Documents/test/test.jpg",
'text' => 'Hello',
];
$ch = curl_init('http://localhost/post.php');
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_VERBOSE, true);
$response = curl_exec($ch);
echo $response;
echo 'REQUEST' . "\n";
print_r($_REQUEST);
echo 'FILES' . "\n";
print_r($_FILES);
Answer the question
In order to leave comments, you need to log in
PHP what version? There was a similar question PHP 5.6 and sending a file via cURL
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question