CodeIgniter Forums

Full Version: How do I upload a file with CURLRequest?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am unable to implement a curl call using the library. I'm trying to write the following command using the library:
curl -i --upload-file /Users/peter/Desktop/superneatimage.png --header "Authorization: Bearer redacted" ''
If you are interested in the documentation, here is a link. I'm trying to share an image and stuck on the upload part. This is what I have tried and I am getting all sorts of errors. Mostly bad requests but from time to time I would get an ssl error

PHP Code:
$client = \Config\Services::curlrequest([], nullnullfalse);
                                    try {
                                        $response $client->request('post'$uploadURL, [
                                        'headers' => [
                                            'Authorization' => 'Bearer ' $Social->AuthorizationToken,
                                            'X-Restli-Protocol-Version' => '2.0.0',
                                            'Content-Type' => 'multipart/form-data',
                                        'multipart' => [
                                            'upload-file' => new CURLFile(realpath("absolutepathtoimage.png"), "image/png""imagename.png"),
                                        'verify' => false
                                    } catch (\CodeIgniter\HTTP\Exceptions\HTTPException $e) {
I am inclined to just use plain curl. Perhaps this library is just not mature enough?