Skip to content

Cannot post files using Request #289

@codealfa

Description

@codealfa

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions