Visual C++ Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript

Visual C++ Examples

CkString
Byte Array
Bounced Mail
Character Encoding
Digital Certificates
Digital Signatures
Email
Encryption
FTP
HTML-to-XML
HTTP
IMAP
MHT / HTML Email
RSA Encryption
S/MIME
Socket
Spider
Tar
Upload
XML
XMP
Zip Compression


More Examples...
Email Object
POP3
SMTP
RSS
Atom
Self-Extractor
Service
PPMD
Deflate
DH Key Exchange
DSA

Unreleased...
Bzip2
LZW
Bz2
Icon

 

 

 

 

 

 

 

 

HTTP Upload

Download Chilkat C++ Libraries for VC++ 8.0 / Win32

Download Chilkat C++ Libraries for VC++ 7.0 / Win32

Download Chilkat C++ Libraries for VC++ 6.0 / Win32

C++ source code to upload one or more files (binary or text) to an HTTP server.

void HttpUpload(void)
    {
    // C++ example to HTTP upload any file to an HTTP server.
    CkHttp http;

    // Unlock once at the beginning of your program.
    http.UnlockComponent("Anything for 30-day trial");

    // Create an HTTP request for file upload.
    CkHttpRequest req;
    req.UseUpload();
    req.put_Path("/freeaspupload/testUpload.asp");

    // The first argument to AddFileForUpload is an arbitrary name,
    // the second argument is a filepath for a file that exists on your local
    // filesystem.
    req.AddFileForUpload("File1","dude.gif");

    // This example will upload 2 files.  To upload additional files,
    // call AddFileForUpload once for each file to be uploaded.
    req.AddFileForUpload("File2","dudeActiveX.gif");

    // Upload the files by calling SynchronousRequest.		
    bool ssl = false;   // Set this to true to use HTTPS

    CkHttpResponse *resp = http.SynchronousRequest("www.freeaspupload.net",80,false,req);
    if (!resp)
	{
	http.SaveLastError("httpError.xml");
	}
    else
	{
	if (resp->get_StatusCode() == 200) 
	    {
	    // Everything is OK.  Show the response information anyway...
	    CkString strStatusLine;
	    resp->get_StatusLine(strStatusLine);
	    printf("StatusLine = [%s]\n",strStatusLine.getString());

	    CkString strBody;
	    resp->get_BodyStr(strBody);
	    printf("--- HTTP Response Body ---\n%s\n",strBody.getString());

	    }
	else
	    {
	    // Print the error...
	    CkString strStatusLine;
	    resp->get_StatusLine(strStatusLine);
	    printf("StatusLine = [%s]\n",strStatusLine.getString());

	    CkString strBody;
	    resp->get_BodyStr(strBody);
	    printf("--- HTTP Response Body ---\n%s\n",strBody.getString());
	    }
	}


    }

 

 

 

Need a specific example? Send a request to support@chilkatsoft.com

© 2000-2008 Chilkat Software, Inc. All Rights Reserved.

Mail Component · .NET Mail Component · XML Parser