note 126681 added to features.file-upload.put-method
| From: | OscarFernandezSierra at main dot php dot net | Date: | Tue, 14 Dec 2021 09:27:37 +0000 |
| Subject: | note 126681 added to features.file-upload.put-method | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-217364@lists.php.net to get a copy of this message | ||
This is what worked for me. There are many examples in the web that don't work. I found in https://lornajane.net/posts/2009/putting-data-fields-with-php-curl.
IMPORTANT: You should not use the code
curl_setopt($ch, CURLOPT_PUT, true);
even if it seems to be the right option (it would be the right option for a POST request, with
CURLOPT_POST, but it does not work for a PUT request).
Notice that the constant CURLOPT_CUSTOMREQUEST is used instead of CURLOPT_PUT, and that the value
used is "PUT" instead of true.
<?php
$url = "....."; // put your URL here
$data = array("a" => $a);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
$response = curl_exec($ch);
if ( ! $response) {
return false;
}
----
Server IP: 45.112.84.4
Probable Submitter: 45.112.85.242 (proxied: 79.147.194.12)
----
Manual Page -- https://php.net/manual/en/features.file-upload.put-method.php
Edit -- https://main.php.net/note/edit/126681
Del: integrated -- https://main.php.net/note/delete/126681/integrated
Del: useless -- https://main.php.net/note/delete/126681/useless
Del: bad code -- https://main.php.net/note/delete/126681/bad+code
Del: spam -- https://main.php.net/note/delete/126681/spam
Del: non-english -- https://main.php.net/note/delete/126681/non-english
Del: in docs -- https://main.php.net/note/delete/126681/in+docs
Del: other reasons-- https://main.php.net/note/delete/126681
Reject -- https://main.php.net/note/reject/126681
Search -- https://main.php.net/manage/user-notes.php