T
T
tincap2015-12-05 12:12:05
Web development
tincap, 2015-12-05 12:12:05

What data should be sent to the server to upload an avatar?

When uploading an avatar to the server, I caught an http request. Is it possible to determine from this data what headers should be sent by the curl to the server in order to load the image? I have all the data. (signature, usersession, file - image)

------moxieboundary1449305658700
Content-Disposition: form-data; name="name"

avatar.jpg
------moxieboundary1449305658700
Content-Disposition: form-data; name="session"

f613616f075734a37fe4be366b94bce93ebd7352cfaa3d6630aa8d3ff8d442ab
------moxieboundary1449305658700
Content-Disposition: form-data; name="username"

tincap_00011
------moxieboundary1449305658700
Content-Disposition: form-data; name="signature"

347c472d00aea7c889ce08a6d5c1de44
------moxieboundary1449305658700
Content-Disposition: form-data; name="file"; filename="avatar.jpg"
Content-Type: image/jpeg

I send data like this, but for some reason the server gives an error [error] => Array
(
[code] => 200
[message] => Unable to move the uploaded file
)
$headerData = [
            'POST /profile/avatar/upload HTTP/1.1',
            'Accept: */*',
            'Accept-Language: ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3',
            'Connection: keep-alive',
            'Pragma: no-cache',
            'Cache-Control: no-cache',
            'Content-Type: multipart/form-data;',
        ];

       $postData = [
            'session' => $signature['session'],
            'signature' => $signature['signature'],
            'username' => $this->username,
            'filename' => 'avatar.jpg',
            'file' => $avatar,
        ];

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question