Skip to content

Instantly share code, notes, and snippets.

@niteshsri
Created April 15, 2018 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save niteshsri/4951c8a67f67c57ed39e9f751048716e to your computer and use it in GitHub Desktop.
Save niteshsri/4951c8a67f67c57ed39e9f751048716e to your computer and use it in GitHub Desktop.
code at server A:
$req=[
'user'=>[
'first_name'=>$data['first_name'],
'last_name'=>$data['last_name'],
'email'=>$data['email'],
'phone'=>$data['phone'],
],
'user_details'=>[
'gender'=>$data['gender'],
'bio'=>$data['bio'],
'dob'=>$data['dob'],
]
];
$data = new FormData();
$file = $data->addFile('imageFile', fopen($this->request->data['profile_image_name']['tmp_name'], 'r'));
$file->contentId($this->request->data['profile_image_name']['name']);
$file->disposition('attachment');
$http = new Client();
$response = $http->put(
<url>,
(string) $data,
['headers' => ['Content-Type' => $data->contentType()]]
);
pr($response->body());die;
code at API server:
pr( $this->request);die;
@niteshsri
Copy link
Author

Cake\Http\ServerRequest Object
(
[params] => Array
(
[pass] => Array
(
)

        [controller] => Users
        [action] => updateBasicProfile
        [_method] => PUT
        [prefix] => cpanel
        [plugin] => 
        [_matchedRoute] => /cpanel/users/update-basic-profile
        [_ext] => 
        [isAjax] => 
    )

[data] => Array
    (
    )

[query] => Array
    (
    )

[cookies] => Array
    (
    )

[_environment:protected] => Array
    (
        [REDIRECT_REDIRECT_STATUS] => 200
        [REDIRECT_STATUS] => 200
        [HTTP_HOST] => localhost
        [CONTENT_LENGTH] => 79621
        [CONTENT_TYPE] => application/json
        [HTTP_CONNECTION] => close
        [HTTP_USER_AGENT] => CakePHP
        [PATH] => /usr/bin:/bin:/usr/sbin:/sbin
        [SERVER_SIGNATURE] => 
        [SERVER_SOFTWARE] => Apache/2.2.34 (Unix) mod_wsgi/3.5 Python/2.7.13 PHP/7.2.1 mod_ssl/2.2.34 OpenSSL/1.0.2j DAV/2 mod_fastcgi/2.4.6 mod_perl/2.0.9 Perl/v5.24.0
        [SERVER_NAME] => localhost
        [SERVER_ADDR] => ::1
        [SERVER_PORT] => 80
        [REMOTE_ADDR] => ::1
        [DOCUMENT_ROOT] => /Applications/MAMP/htdocs
        [SERVER_ADMIN] => you@example.com
        [SCRIPT_FILENAME] => /Applications/MAMP/htdocs/ph_backend/webroot/index.php
        [REMOTE_PORT] => 59353
        [REDIRECT_URL] => /ph_backend/webroot/cpanel/users/update-basic-profile
        [GATEWAY_INTERFACE] => CGI/1.1
        [SERVER_PROTOCOL] => HTTP/1.1
        [REQUEST_METHOD] => PUT
        [QUERY_STRING] => 
        [REQUEST_URI] => /ph_backend/cpanel/users/update-basic-profile
        [SCRIPT_NAME] => /ph_backend/webroot/index.php
        [PHP_SELF] => /ph_backend/webroot/index.php
        [REQUEST_TIME_FLOAT] => 1523801616.962
        [REQUEST_TIME] => 1523801616
        [argv] => Array
            (
            )

        [argc] => 0
        [ORIGINAL_REQUEST_METHOD] => PUT
        [HTTP_ORIGIN] => 
        [HTTP_ACCEPT] => application/json
        [HTTPS] => 
        [HTTP_X_REQUESTED_WITH] => 
        [HTTP_AUTHORIZATION] => 
    )

[url] => cpanel/users/update-basic-profile
[base] => /ph_backend
[webroot] => /ph_backend/
[here] => /ph_backend/cpanel/users/update-basic-profile
[trustProxy] => 
[_input:protected] => 
[_detectorCache:protected] => Array
    (
        [ssl] => 
        [ajax] => 
        [get] => 
        [head] => 
        [options] => 
        [post] => 
        [put] => 1
    )

[stream:protected] => Zend\Diactoros\PhpInputStream Object
    (
        [cache:Zend\Diactoros\PhpInputStream:private] => --c3beca06404cc2c3c2f16a83dd43cb91

Content-Disposition: attachment; name="imageFile"; filename="phpm05imk"
Content-Type: image/jpeg; charset=binary
Content-ID:

�����JFIF������C���������� �

�� ������������� $.' ",#��(7),01444�'9=82<.342��C� � �

�2!�!22222222222222222222222222222222222222222222222222����������"������������������������������������ �������� ��bi�&&7Q�� �H@�0��,��
�f��4�����"�)e�Ŵ�iu���r�+3��Fk��4�2�^�5�\�!������& �L�� �M�L���j��
��&��B��@���)1BEsVF6�e���n��$�f�3%�sKKh,�k�w.�鲤�ȕ��0�QVȘ���[.SN��U�������@Ā"0@P��� �My� �R���@��1��1��
ښ��˚�3���u�j��s�ȹ��Yw_;��{�'�^��y�;t�;Uu��x.�5��qЖ�[������%��*\B�%(�],�5��h��
�!&���0����nWc�R���@P ���0�!�
��Pq�Z]�F%+�M+�������]��������_=ɒ�a+��P��潥���!���Nr���z����u"��d�R�2�Q� N�G����9芥D��@��j��#B��ʉ%��q�� א����0�$S��
�E��L�ۃR��δWs���k�d��~:i�0�s�;c6e%=��j(N��+�3��#��%��w�q�r �$�����O*�5jB�p1�+*S�Ȱ��5�E�\���ZV�ht���M���Nm��+�͆�����
HD�4��� "I@IJ�����J�h%dj����R��)�����.}���jR��l�e��q�f��

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment