HTTP Client data container for form(multipart/form-data)

Dependencies:   mbed EthernetInterface HTTPClient mbed-rtos

Revision:
0:fcd577a3925b
Child:
1:77c616a1ab54
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/file_upload.cpp	Thu May 31 10:32:39 2012 +0000
@@ -0,0 +1,29 @@
+#include "mbed.h"
+#include "EthernetNetIf.h"
+#include "HTTPClient.h"
+#include "HTTPPoster.h"
+
+LocalFileSystem local("local"); 
+
+Serial pc(USBTX, USBRX);
+
+EthernetNetIf eth;
+
+int main() {
+    pc.baud(921600);
+
+    int ethErr = eth.setup();
+    if(ethErr) {printf("Error %d in setup.\n", ethErr); exit(1);}
+
+    HTTPClient client;
+    HTTPPoster data;
+    data.addFile("image", "/local/image.jpg");
+    data.add("title", "hello");
+    string url = "http://va009039.appspot.com/mbed/upload/";
+    
+    HTTPResult r = client.post(url.c_str(), data, NULL);
+
+    printf("result:%d HTTPResponseCode: %d\n", r, client.getHTTPResponseCode());
+
+    exit(1);    
+}