Question about posting a file

Login to reply to this topic.
Tue, 2007-06-26 16:07
Joined: 2007-06-26
Forum posts: 1

Hi,

I am able to send postdata to the webserver. Everything works fine. But now I also want to send a image (jpeg). I try a few things but I am not sure how to do this.

Does any one has experience with sending a binary file with http post? Smiling

1) How to read such a image and
2) How to put it in postData?

Thanks!

TBuf<KDefaultBufferSize> postData;
TBuf8<KDefaultBufferSize> postData8;

postData.Append(_L("--AaB03x\r\n"));
postData.Append(_L("content-disposition: form-data; name=\"naam\"\r\n\r\n"));
postData.Append(_L("heinolenting\r\n"));

postData.Append(_L("--AaB03x\r\n"));
postData.Append(_L("content-disposition: form-data; name=\"number\"\r\n\r\n"));
postData.Append(_L("343243\r\n"));

postData.Append(_L("--AaB03x\r\n"));
postData.Append(_L("content-disposition: form-data; name=\"userfile\"; filename=\"testing.jpg\"\r\n"));
postData.Append(_L("content-type: image/jpeg\r\n\r\n"));
postData.Append(_L("thecontentoftheimage"));
postData.Append(_L("\r\n"));
postData.Append(_L("--AaB03x--\r\n"));

postData8.Copy(postData);

  • Login to reply to this topic.