-
Notifications
You must be signed in to change notification settings - Fork 499
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot post files using Request #289
Comments
Meet this problem too, just want to replace it with the guzzle ... |
Inspired by WordPress#289
Next up: test multiple files, request_multi See WordPress#289
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.
|
The interface has changed to:
|
when is this planned to be released? :) |
No idea, check out #313 |
I have refreshed the file uploading code 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? |
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.
The text was updated successfully, but these errors were encountered: