mardi 30 décembre 2014

Use curl to send binary file through POST with content-type multipart/form-data;


A post request is made to:



http://www.example.com/example/


and the post data is as follows:



------WebKitFormBoundaryB8NNdk2kNdndnnn
Content-Disposition: form-data; name="picture[uploaded_data]"; filename="picture.jpg"
Content-Type: image/jpeg

binarydatagoeshere
------WebKitFormBoundaryB8NNdk2kNdndnnn--


So my question is, how can i use curl to do this exact same thing with the binary data of picture.jpg? I know of --data-binary @myfile.bin, but this is completely different and in this case the string after Boundary e.g B8NNdk2kNdndnnn in this case needs to be valid for the request to go through. So how do i do all this using curl?



Aucun commentaire:

Enregistrer un commentaire