HTTP POST - HTML FORM Submission Data (Using CHTTPFormEncoder)

Login to reply to this topic.
Fri, 2005-06-03 05:22
Joined: 2004-10-25
Forum posts: 69
 Hello,

I am able to successfully post a picture to the server ( just binary)
using the following code.
Code:
case EClientPost:
{
// Issue HTTP post to engine

iClient->CancelTransaction();

// URL to post the picture
TBuf8<256> uri8;
uri8.Copy(KTestURL);

TBuf<50> aFileName = _L("c:\\image.jpg"); // 30KB Image to be uploaded

HBufC8* postData8 = ReadFileLC(aFileName);

// Start transaction
iClient->IssueHTTPPostL(uri8, _L8("*/*"), *postData8);

}
Now I want to post both text (xml) and binary ( image) so I am trying to put them
into a CHTTPFormEncoder ( name-value pairs). This is how I try to do it.

Code:
                TBuf<50> aFileName1 = _L("c:\\xml.txt"); // XML control message
TBuf<50> aFileName2 = _L("c:\\image.jpg"); // 30KB Image to be uploaded

HBufC8* xml_part = ReadFileLC(aFileName1);
HBufC8* binary_part = ReadFileLC(aFileName2);


// Start transaction
iClient->IssueHTTPPostL(uri8, _L8("application/x-www-form-urlencoded"), *xml_part, *binary_part);



Now in the IssueHTTPPostL() method - I need to combine the 2 data in to name-value pairs
      
      CHTTPFormEncoder* postData8; // = CHTTPFormEncoder::NewL();
      postData8->AddFieldL(_L8("xml"),*xml_part);
      postData8->AddFieldL(_L8("file_upload"), *binary_part);

Sat, 2005-09-24 11:09
Joined: 2005-09-24
Forum posts: 3
Re: HTTP POST - HTML FORM Submission Data (Using CHTTPFormEncode
Your code is very nice however, how did you implement ReadFileLC()?

Thanks.
Mon, 2006-08-21 10:25
Joined: 2005-07-04
Forum posts: 59
Re: HTTP POST - HTML FORM Submission Data (Using CHTTPFormEncode
Any idea on how ReadFileLC was implemented?
  • Login to reply to this topic.