Skip to content
Advertisement

Image upload using curl

I want to upload image to remote site using curl cli version, i browse several pages here, but not able to solve my problem. I log http header in firefox while uploading image:

https://www.site.xxx/upload_profile_picture/

POST /upload_profile_picture/ HTTP/1.1
Host: www.site.xxx
User-Agent: Mozilla/5.0 (Linux; U; Android 4.0.3; ko-kr; LG-L160L Build/IML74K) AppleWebkit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30
Accept: */*
Accept-Language: en-gb,en;q=0.5
Accept-Encoding: gzip, deflate
X-Requested-With: XMLHttpRequest
Content-Type: multipart/form-data; boundary=---------------------------124439777612656977621176581961
Cookie: 123
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache


BELOW IS POSTDATA:::
-----------------------------124439777612656977621176581961
Content-Disposition: form-data; name="profile_pic"; filename="7eddaf78bbd055460167bae9eee3cdea.jpg"
Content-Type: image/jpeg

ÿØÿà

Advertisement

Answer

The basic curlsyntax would be

curl -F "image=@/yourPath/yourImageFile.jpg" 'https://www.site.xxx/upload_profile_picture/'

Specify other POST data fields with one or several additional -F options if necessary, as in -F "username=xxx".

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement