L_InetHttpSendData

#include "ltweb.h"

L_INT EXT_FUNCTION L_InetHttpSendData(hHttp, pData, uSize, pszContentType, pNameValue)

HINET hHttp;

/* handle to an HTTP connection*/

L_CHAR L_FAR *pData;

/* pointer to the data to send*/

L_UINT32 uSize;

/* size of pData*/

L_TCHAR L_FAR *pszContentType;

/* HTTP content type*/

pNAMEVALUE pNameValue;

/* pointer to a structure */

Sends raw data to an HTTP server.

Parameter

Description

hHttp

Handle to the HTTP connection. It is the same handle obtained using the L_InetHttpConnect function.

pData

Pointer to data to send in the HTTP request.

uSize

Size of pData.

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 Internet 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 L_InetHttpOpenRequest 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:

L_InetHttpSendBitmap, L_InetHttpSendForm, L_InetHttpSendRequest

Topics:

HTTP Functions: Sending Data Over a HTTP Connection

 

Working with HTTP Functions

Example

void TestSendData(L_CHAR L_FAR *pData, L_UINT32 uSize)
{
   HINET hInet;
   L_INT nRet;

   nRet = L_InetHttpConnect(TEXT("www.leadtools.com"),80, TEXT(""),TEXT(""),&hInet);
   if(nRet==SUCCESS)
   {
      nRet = L_InetHttpOpenRequest(hInet,HTTP_GET, TEXT("/upload.asp"), TEXT(""),TEXT("HTTP/1.0"),0);
      if(nRet==SUCCESS)
      {
         L_TCHAR szResponse[2048];
         L_UINT32 lsize;
         L_UINT uStatus;
         FILE *fp;
         NAMEVALUE nv;

         nv.pszName = TEXT("Data");
         nv.pszValue = TEXT("data1.raw");
         nRet=L_InetHttpSendData(hInet,pData,uSize, TEXT("image/jpg"),&nv);
         if(nRet!=SUCCESS)
         {
            MessageBox(NULL,TEXT("Error Sending Form"),TEXT("Error"),MB_ICONEXCLAMATION);
            L_InetHttpCloseRequest(hInet);
            L_InetHttpDisconnect(hInet);
            return;
         }
         L_InetHttpGetServerStatus(hInet,&uStatus);
         if(uStatus==L_HTTP_STATUS_OK)
         {
            lsize = 2048;
            L_InetHttpGetResponse(hInet,szResponse,&lsize);
            #ifdef UNICODE

               fp = _wfopen(TEXT("output.htm"),TEXT("wb"));
            #else

               fp = fopen("output.htm","wb");
            #endif

            while(lsize!=0)
            {
               fwrite(szResponse,lsize,1,fp);
               lsize = 1048;
               L_InetHttpGetResponse (hInet,szResponse,&lsize);
            }
            fclose(fp);
         }
         else
         {

            MessageBox(NULL,TEXT("Problem With Server"),TEXT("Error"),MB_ICONEXCLAMATION);
            lsize = 2048;
            L_InetHttpGetResponse (hInet,szResponse,&lsize);
            #ifdef UNICODE

               fp = _wfopen(TEXT("error.htm"),TEXT("wb"));
            #else

               fp = fopen("error.htm","wb");
            #endif

            while(lsize!=0)
            {
               fwrite(szResponse,lsize,1,fp);
               lsize = 1048;
               L_InetHttpGetResponse(hInet,szResponse,&lsize);
            }
            fclose(fp);
         }
         L_InetHttpCloseRequest(hInet);
      }
      L_InetHttpDisconnect(hInet);
   }
}

The upload.asp file for the L_InetHttpSendBitmap function can also be used with this example.