Cannot post files using Request
It's impossible to post files by http using cURL via the Request API.
If you look at the code in the setup_handle method in Requests_Transport_cURL class found in the /Requests/Transport/cURL.php file, you'll see that the POST data is always converted to a string using the PHP http_build_query function. However, according to the PHP manual, the value passed to CURLOPT_POSTFIELDS must be an array if files are passed to this option.
A possible fix could be to simply add the post value to the CURLOPT_POSTFIELDS option as an array if the Content-Type header has been given as multipart/form-data. It would be converted to a query string otherwise. According to the PHP manual, the multipart/form-data Content-Type header will be set if the post value is an array.
Meet this problem too, just want to replace it with the guzzle ...
Help test https://github.com/soulseekah/Requests/tree/feature-upload and provide ideas please. A fifth parameter was introduced (just like Python Requests) to ::post and ::request - $files. Simply supply a file path and magic should happen.
$response = Requests::post('https://httpbin.org/post', array(), array('foo'=>'bar'), array(), array('file1' => '/tmp/yourfile'));
The interface has changed to:
Requests::post('https://httpbin.org/post', array(), array('foo'=>'bar', 'file'=>new Requests_File('path/to/file'))
when is this planned to be released? :)
No idea, check out https://github.com/rmccue/Requests/pull/313
I have refreshed the file uploading code and added an helper function \WpOrg\Requests\Requests::add_files_to_body() to make it easier to attach files
I am sure there will be more changes but I thought I would have a go and get this feature moving forward
This isn't still released? What a shame.
soon I hope
What is the status of this?