Wife/Girlfriend/Sister?
Pepper Spray &
Stun Gun Specials!
KEEP THEM SAFE.
 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
37 active users
1887 visitors today
2478 pages today
(only part of today)
Tools I use

CoverYourASP
Copyright © 1999-2010 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


CoverYourASP Mugs, T-shirts, caps - even Boxer shorts...
I don't make a penny from these, but they're a lot of fun! Don't you need a new mouse mat?


I share my content

Supporting ASPRSS

Do you need a quick and easy way to link to my articles? All the information you need is published with ASPRSS...