LInetHttp::SendData

#include "ltwrappr.h"

L_INT LInetHttp::SendData(pData, pszContentType, pNameValue)

L_INT LInetHttp::SendData(pszData, uSize, pszContentType, pNameValue)

LBuffer *pData;

/* pointer to an LBuffer object */

L_CHAR *pszData;

/* pointer to the data to send */

L_UINT32 uSize;

/* size of pszData */

L_TCHAR *pszContentType;

/* HTTP content type */

pNAMEVALUE pNameValue;

/* pointer to a structure */

Sends raw data to an HTTP server.

Parameter

Description

pData

Pointer to an LBuffer classes object referencing the data to send.

pszData

Pointer to data to send in the HTTP request.

uSize

Size of pszData.

pszContentType

A string describing the content type. This string is usually formatted type/subtype where type is the general content category and subtype is the specific content type. For a full list of supported content types, see your Web browser documentation or the current HTTP specification.

pNameValue

A pointer to the structure that contains the name/value pair for this image. This information is used to get the information from a script on the server machine. This name is usually some user-defined name and the value is the filename of the data.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

It is up to a script on the server side to process the data when it is received. This script is specified in the LInetHttp::OpenRequest function. The script can be any type of file that is recognized by the HTTP Server.

Note: The LEADTOOLS Uploading Component can be used in an ASP page to extract the uploaded data.

Required DLLs and Libraries

LTWEB

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application

See Also

Functions:

LInetHttp::OpenRequest, LInetHttp::SendBitmap, LInetHttp::SendForm, LInetHttp::SendRequest, Class Members

Topics:

HTTP Functions: Sending / Getting Data

 

How to Program with the LInetHttp Class

Example

The upload.asp file for the LInetHttp::SendBitmap function can also be used with these samples.

/*The following sample is for LInetHttp::SendData(pData, pszContentType, pNameValue)*/
// This sample sends raw data to the HTTP web server
L_INT LInetHttp_SendDataExample(LBuffer Data, HWND hWndParent)
{
   L_INT       nRet;
   NAMEVALUE   nv;
   LInetHttp   InetHttp(TEXT("www.leadtools.com"));
   // Checking if the connection failed
   nRet = InetHttp.GetErrorFromList ();
   if(nRet != SUCCESS)
   {
      InetHttp.DisplayError (hWndParent, TEXT("Can't connect to the HTTP web server"));
      return nRet;
   }
   nRet = InetHttp.OpenRequest(HTTP_POST, TEXT("/upload.asp"));
   if(nRet != SUCCESS)
   {
      InetHttp.DisplayError(hWndParent, TEXT("Can't open a request"));
      return nRet;
   }
   nv.pszName = TEXT("Data");
   nv.pszValue = TEXT("data1.raw");
   nRet = InetHttp.SendData (&Data, TEXT("image/jpg"), &nv);
   if(nRet != SUCCESS)
   {
      InetHttp.DisplayError(hWndParent, TEXT("Can't send an image, an error may occurred"));
      return nRet;
   }
   return SUCCESS;
}
//---------------------------------------------------------------------------------------------------------------
/*The following sample is for LInetHttp::SendData(pszData, uSize, pszContentType, pNameValue)*/
// This sample also sends raw data to the HTTP web server
L_INT SendDataExample_2(L_CHAR *pszData, L_UINT32 ulSize, HWND hWndParent)
{
   L_INT       nRet;
   NAMEVALUE   nv;
   LInetHttp   InetHttp(TEXT("www.leadtools.com"));
   // Checking if the connection failed
   nRet = InetHttp.GetErrorFromList ();
   if(nRet != SUCCESS)
   {
      InetHttp.DisplayError (hWndParent, TEXT("Can't connect to the HTTP web server"));
      return nRet;
   }
   nRet = InetHttp.OpenRequest (HTTP_POST, TEXT("/upload.asp"));
   if(nRet != SUCCESS)
   {
      InetHttp.DisplayError(hWndParent, TEXT("Can't open a request"));
      return nRet;
   }
   nv.pszName = TEXT("Data");
   nv.pszValue = TEXT("data1.raw");
   nRet = InetHttp.SendData(pszData, ulSize, TEXT("image/jpg"), &nv);
   if(nRet != SUCCESS)
   {
      InetHttp.DisplayError (hWndParent, TEXT("Can't send an image, an error may occurred"));
      return nRet;
   }
   return SUCCESS;
}