Home » Developing U++ » U++ Developers corner » MultipartForm Class for use w/HttpClient
MultipartForm Class for use w/HttpClient [message #28074] |
Sat, 14 August 2010 17:18 |
jeremy_c
Messages: 175 Registered: August 2007 Location: Ohio, USA
|
Experienced Member |
|
|
I created a class named MultipartForm that can be used w/Http(s)Client. It allows one to do file uploads. I know this will be of use to others as the question has come up on the forum a few times. What I don't know is the best way to share it or get feedback on it. Here's a sample use:
MultipartForm form;
form.Set("name", "John Doe");
form.Set("age", "18");
form.SetFile("bio", "mybio.txt", LoadFile("mybio.txt"));
form.SetFile("avatar", "me.jpg", Base64Encode(LoadFile("me.jpg")), "base64");
HttpClient http("http://localhost/upload.cgi");
http.ContentType(form.GetContentType());
http.Post(form.ToString());
That's basically it. In the end it creates a properly formatted multipart/form-data submission.
Jeremy
|
|
|
Goto Forum:
Current Time: Thu May 16 18:12:10 CEST 2024
Total time taken to generate the page: 0.01763 seconds
|