src/Twitter/Connections/UserConnection.php
public function uploadMedia($filepaths, $client = null)
    {

        //maximum number of media files that a user can upload
        $maxMediaIds = Config::get('max_media_ids');

        //if number of media files supplied is larger than $maxMediaIds, throw exception.
        if(count($filepaths) > $maxMediaIds)
        {
            throw new MediaUploadLimitException("You cannot upload more than ${maxMediaIds} media files in a tweet!");
        }

        //array list of media id's uploaded
        $mediaIds = array();

        //create a new Guzzle client, if the user hasn't injected anything!
        if(is_null($client))
        {
            $client = $this->createGuzzleClient(Config::get('base_upload_url'));
        }

        //prepend Twitter's API version to the endpoint
        $endpoint = $this->prependVersionToEndpoint("media/upload.json", Config::get('api_version'));

        //iterate over each filepath
        foreach ($filepaths as $filepath)
        {

            //contruct an options array to configure the request
            $options = $this->constructRequestOptions(array(), $client);

            //add body options to the POST request
            $options['body'] = array (
                'media' => new PostFile('media', fopen($filepath, 'r'))
            );

            //make the POST request to the endpoint with the constructed options.
            $response = $client->post($endpoint, $options);

            //add media_id to array
            array_push($mediaIds, $response->json()['media_id_string']);

        }

        //return all media ID's as a string (comma seperated)
        return (implode(",", $mediaIds));

    }
public function uploadMedia($filepaths, $client = null)
    {

        //maximum number of media files that a user can upload
        $maxMediaIds = Config::get('max_media_ids');

        //if number of media files supplied is larger than $maxMediaIds, throw exception.
        if(count($filepaths) > $maxMediaIds)
        {
            throw new MediaUploadLimitException("You cannot upload more than ${maxMediaIds} media files in a tweet!");
        }

        //array list of media id's uploaded
        $mediaIds = array();

        //create a new Guzzle client, if the user hasn't injected anything!
        if(is_null($client))
        {
            $client = $this->createGuzzleClient(Config::get('base_upload_url'));
        }

        //prepend Twitter's API version to the endpoint
        $endpoint = $this->prependVersionToEndpoint("media/upload.json", Config::get('api_version'));

        //iterate over each filepath
        foreach ($filepaths as $filepath)
        {

            //contruct an options array to configure the request
            $options = $this->constructRequestOptions(array(), $client);

            //add body options to the POST request
            $options['body'] = array (
                'media' => new PostFile('media', fopen($filepath, 'r'))
            );

            //make the POST request to the endpoint with the constructed options.
            $response = $client->post($endpoint, $options);

            //add media_id to array
            array_push($mediaIds, $response->json()['media_id_string']);

        }

        //return all media ID's as a string (comma seperated)
        return (implode(",", $mediaIds));

    }
Upload media to Twitter and return a comma separated string containing their
media ID's to send with a status.

@param  array $filepaths should be a maximum of 4
@param  GuzzleHttp\Client $client Optional. To inject your own instance of Guzzle. The base_url of the injected client should be set to Config::get('base_upload_url').

@return string|false If a ServerException occurs, return false.