Hi All,
I want to post/upload an image to URL like http://xyz.com.
I'm posting data as a form content code is given below.
How do I post an image. Is it possible to post it just using image path? or do I need image content like binary data.
It should be like we do in HTML <input type="submit" value="Send"> and selected file gets uploaded.
I got image path now can u please tell the way to post it using path.
TUriParser8 uri;
uri.Parse(*iUri);
// Copy data to be posted into member variable; iPostData is used later in
// methods inherited from MHTTPDataSupplier.
delete iPostData;
iPostData = 0;
iPostData = iBody->AllocL();
// Get request method string for HTTP POST
//RStringF method = iSession.StringPool().StringF(HTTP::EPOST,RHTTPSession::GetTable());
RStringF method = iSession.StringPool().StringF(HTTP::EPOST,RHTTPSession::GetTable());
// Open transaction with previous method and parsed uri. This class will
// receive transaction events in MHFRunL and MHFRunError.
iTransaction = iSession.OpenTransactionL(uri, *this, method);
iTransactionOpen = ETrue;
// Set headers for request; user agent, accepted content type and body's
// content type.
RHTTPHeaders hdr = iTransaction.Request().GetHeaderCollection();
SetHeaderL(hdr, HTTP::EUserAgent, KUserAgent);
SetHeaderL(hdr, HTTP::EAccept, KAccept);
SetHeaderL(hdr, HTTP::EContentType, KContentTypeForm);
// Set this class as an data supplier. Inherited MHTTPDataSupplier methods
// are called when framework needs to send body data.
MHTTPDataSupplier* dataSupplier = this;
iTransaction.Request().SetBody(*dataSupplier);
// Submit the transaction. After this the framework will give transaction
// events via MHFRunL and MHFRunError.
iTransaction.SubmitL();
Regards,

Reply With Quote

