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 L_FAR *pszData;

/* pointer to the data to send */

L_UINT32 uSize;

/* size of pszData */

L_TCHAR L_FAR *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_VOID TestSendData(LBuffer Data, HWND hWndParent)
{
   NAMEVALUE nv;
   LInetHttp   InetHttp(TEXT("www.leadtools.com"));

   // Checking if the connection failed
   if(InetHttp.GetErrorFromList () != SUCCESS)
   {
      InetHttp.DisplayError (hWndParent, TEXT("Can't connect to the HTTP web server"));
      return;
   }

   if(InetHttp.OpenRequest(HTTP_POST, TEXT("/upload.asp")) != SUCCESS)
   {
      InetHttp.DisplayError(hWndParent, TEXT("Can't open a request"));
      return;
   }
   nv.pszName = TEXT("Data");
   nv.pszValue = TEXT("data1.raw");

   if(InetHttp.SendData (&Data, TEXT("image/jpg"), &nv) != SUCCESS)
   {
      InetHttp.DisplayError(hWndParent, TEXT("Can't send an image, an error may occurred"));
      return;
   }
}

//---------------------------------------------------------------------------------------------------------------

/*The following sample is for LInetHttp::SendData(pszData, uSize, pszContentType, pNameValue)*/

// This sample also sends raw data to the HTTP web server

L_VOID TestSendData(L_CHAR L_FAR *pszData, L_UINT32 ulSize, HWND hWndParent)
{
   NAMEVALUE nv;
   LInetHttp   InetHttp(TEXT("www.leadtools.com"));

   // Checking if the connection failed
   if(InetHttp.GetErrorFromList () != SUCCESS)
   {
      InetHttp.DisplayError (hWndParent, TEXT("Can't connect to the HTTP web server"));
      return;
   }

   if(InetHttp.OpenRequest (HTTP_POST, TEXT("/upload.asp")) != SUCCESS)
   {
      InetHttp.DisplayError(hWndParent, TEXT("Can't open a request"));
      return;
   }
   nv.pszName = TEXT("Data");
   nv.pszValue = TEXT("data1.raw");

   if(InetHttp.SendData(pszData, ulSize, TEXT("image/jpg"), &nv) != SUCCESS)
   {
      InetHttp.DisplayError (hWndParent, TEXT("Can't send an image, an error may occurred"));
      return;
   }
}