Reputation: 21
I am trying to use libcurl for uploading a file via POST using the CURLOPT_UPLOAD option:
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
By default, it uses PUT as explained here, where it is mentioned: If the protocol is HTTP, uploading means using the PUT request unless you tell libcurl otherwise. How do I tell libcurl otherwise, specifically, to use POST.
I have tried adding the following after the previous line of code above, but it did not work:
curl_easy_setopt(curl, CURLOPT_POST, 1L);
Upvotes: 1
Views: 405
Reputation: 18410
You can use CURLOPT_CUSTOMREQUEST
for that:
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
This method is suitable for setting any custom HTTP method for your request.
For more details, see the corresponding page in the curl manual
Upvotes: 1