public function upload($params, $optParams = [])
    {
        $resource = null;
        if (is_string($params) || is_resource($params)) {
            $params = ['file' => $params];
        } elseif (is_array($params) && isset($params['tmp_name'])) {
            $params = ['file' => $params['tmp_name']];
        }
        if (isset($params['file']) && is_array($params['file']) && isset($params['file']['tmp_name'])) {
            $params['file'] = $params['file']['tmp_name'];
        }
        if (isset($params['file']) && is_string($params['file'])) {
            $resource = $params['file'] = fopen($params['file'], 'r');
        }
        ArrayHelper::stringify($optParams, [
            'transformation',
        ]);

        return $this->sendRequest(['cloudId', 'file'], [
            'restAction' => 'create',
            'uri' => '/c/<cloudId>',
            'params' => $params,
            'postParams' => array_merge($params, $optParams),
        ], function ($response) use ($resource) {
            if (is_resource($resource)) {
                fclose($resource);
            }

            return isset($response->data) ? new Image($response->data) : $response;
        });
    }
public function upload($params, $optParams = [])
    {
        $resource = null;
        if (is_string($params) || is_resource($params)) {
            $params = ['file' => $params];
        } elseif (is_array($params) && isset($params['tmp_name'])) {
            $params = ['file' => $params['tmp_name']];
        }
        if (isset($params['file']) && is_array($params['file']) && isset($params['file']['tmp_name'])) {
            $params['file'] = $params['file']['tmp_name'];
        }
        if (isset($params['file']) && is_string($params['file'])) {
            $resource = $params['file'] = fopen($params['file'], 'r');
        }
        ArrayHelper::stringify($optParams, [
            'transformation',
        ]);

        return $this->sendRequest(['cloudId', 'file'], [
            'restAction' => 'create',
            'uri' => '/c/<cloudId>',
            'params' => $params,
            'postParams' => array_merge($params, $optParams),
        ], function ($response) use ($resource) {
            if (is_resource($resource)) {
                fclose($resource);
            }

            return isset($response->data) ? new Image($response->data) : $response;
        });
    }
public function upload ( $ params , $ optParams = [ ] ) { $ resource = null ; if ( is_string ( $ params ) || is_resource ( $ params ) ) { $ params = [ 'file' => $ params ] ; } elseif ( is_array ( $ params ) && isset ( $ params [ 'tmp_name' ] ) ) { $ params = [ 'file' => $ params [ 'tmp_name' ] ] ; } if ( isset ( $ params [ 'file' ] ) && is_array ( $ params [ 'file' ] ) && isset ( $ params [ 'file' ] [ 'tmp_name' ] ) ) { $ params [ 'file' ] = $ params [ 'file' ] [ 'tmp_name' ] ; } if ( isset ( $ params [ 'file' ] ) && is_string ( $ params [ 'file' ] ) ) { $ resource = $ params [ 'file' ] = fopen ( $ params [ 'file' ] , 'r' ) ; } ArrayHelper :: stringify ( $ optParams , [ 'transformation' , ] ) ; return $ this -> sendRequest ( [ 'cloudId' , 'file' ] , [ 'restAction' => 'create' , 'uri' => '/c/<cloudId>' , 'params' => $ params , 'postParams' => array_merge ( $ params , $ optParams ) , ] , function ( $ response ) use ( $ resource ) { if ( is_resource ( $ resource ) ) { fclose ( $ resource ) ; } return isset ( $ response -> data ) ? new Image ( $ response -> data ) : $ response ; } ) ; }
Uploads an image from a local source.

@param array|string|resource $params Required API parameters

<li>file - source (string - filepath, array - a $_FILES entry,
resource - an opened file resource (@see fopen()),
an array with a 'file' key consisting of the above 3)
<li>cloudId - cloud ID
@param array $optParams Optional API parameters

<li>publicId - image ID
<li>format - image format
<li>transformation - transformations
<li>tags - tags
<li>plugins - plugins

@return Image|Response
Uploads an image from a local source .