As I see file uploads are still not possible, even though the fix was suggested some 4 years ago.
Currently I needed to post files and I wasn't in the mood for rewriting stuff in my app, so this is what I came up with:
$hooks = new Requests_Hooks();
$hooks->register('curl.before_send', function ($ch) {
if (function_exists('curl_file_create')) { // php 5.5+
$cFile = curl_file_create($_FILES['uploadFile']['tmp_name'], '', $_FILES['uploadFile']['name']);
} else { //
$cFile = '@' . realpath($_FILES['uploadFile']['tmp_name']);
}
$_POST['uploadFile'] = $cFile;
curl_setopt($ch, CURLOPT_POSTFIELDS, $_POST);
});
$resp = Requests::post($url, $headers, [], $options);
Just sharing in case it helps someone.
Close when #313 is ready :)
As I see file uploads are still not possible, even though the fix was suggested some 4 years ago.
Currently I needed to post files and I wasn't in the mood for rewriting stuff in my app, so this is what I came up with:
Just sharing in case it helps someone.
Close when #313 is ready :)