ASP/.NET Web Hosting
* 3 Months FREE *
CLICK HERE!
 CoverYourASP --> Get the News --> Part 4

Free membership

Join in the fun! Sign in
Member Services

Site navigation
Download the entire site!
Search my articles
Free Magazines
Browse the directory

Send me feedback
Buy my boxer shorts

Recommend this page
Printer-friendly page

Resources I recommend
Link to my site
Advertising slashed!
About your privacy
Legal stuff
Site statistics
80 active users
2638 visitors today
4730 pages today
how is this done?
Tools I use

CoverYourASP
Copyright © 1999-2008 James Shaw.
All rights reserved.

ASP.NET Blog
RSS submissions
E-commerce

Now open source with SourceForge!

Uploading a file via FTP is almost exactly the same as the way I used HTTP objects earlier - I call CInternetSessions' GetFtpConnection method:

// now upload file to my website
if ( !AfxParseURL ( sSendToURL, dwServiceType, sServerName, sObject, nPort ) )
   throw;

// open FTP connection
pFTPServer = csiSession.GetFtpConnection ( sServerName, _T( "username" ), _T( "password" ), nPort );

// change to utils folder
pFTPServer->SetCurrentDirectory ( _T( "utils" ) );

// put the new file in the folder
pFTPServer->PutFile ( sNewsFile, sNewsFile );
When run, the application finally displays the page on my website where the news is displayed, so I can check it all worked correctly. You can get the full source code below.

Writing this code is an excellent way to introduce yourself to MFC's internet objects. Remember that these are all available to use just as easily from a COM component too. Have fun!

Featured sponsor
My favorite resources

Tiki Statues - Tiki Masks - Tiki Totems



Qualify for Free Trade Magazines

Free subscriptions to industry leading publications for those who qualify!


See my source code
wherever you see this icon...

You can also download the entire site source code for FREE!