Visual Basic Code of the Week (COTW)
http://www.codeoftheweek.com
Issue #106
Online Version at http://www.codeoftheweek.com/membersonly/bi/0106.html (paid subscribers only)
All content and source code is Copyright (c) 1999 by C&D Programming Corp. No part of this issue can be reprinted or distributed in any manner without express written permission of C&D Programming Corp.

Issue topic: Uploading files using FTP (Enhancing the FTP class from issue #56)

Six months of VB Training for only $49.99

Want to get up to speed on the latest Visual Basic programming? Includes Visual Basic 6 and Visual InterDev 6. Check out our training programs at http://www.codeoftheweek.com/vbtraining.html

Get paid to surf the web!

If you would like to get paid for surfing the web, jump to http://www.codeoftheweek.com/paidsurf.html

Requirements

In this Issue

This issue enhances the code introduced in issue number 54 and 56. It shows how to use the Microsoft WININET.DLL to upload a file to any FTP server. It does not use the Microsoft Internet Controls, so there is one less file you have to worry about including with your application.

Be sure to refer to the documentation from issue 56 ( http://www.codeoftheweek.com/issues/0056.html ) for complete details on the events raised to show the status of your transfer.

If you have any questions about using this module, let us know at questions@codeoftheweek.com

Methods

Public Sub UploadWithStatus()

Starts the upload process based on the values supplied to the properties: ServerName, SourceFilename, DestinationFilename, Username, and Password. SourceFilename should contain the full path and filename of the file which you are sending to the FTP server. DestinationFilename should also contain the full path and filename of the file that will be saved on the FTP server relative to the FTP server (for example: /users/home/david/files.txt).

Various errors will be raised to indicate failure. If the file succeeds it will return to the caller without any errors being raised.

Sample Usage

The below sample will upload a file called c:\temp\test.txt to a file called /usr/home/david/testfile.txt on ftp server ftp.codeoftheweek.com

   Set ftp = New cFTP
   ftp.DestinationFilename = "/usr/home/david/testfile.txt"
   ftp.SourceFilename = "c:\temp\test.txt"
   ftp.ServerName = "ftp.codeoftheweek.com"
   ftp.Username = "user"
   ftp.Password = "password"
   On Error Resume Next
   ftp.UploadWithStatus
   If Err Then
      MsgBox Err.Description
   End If

Source Code

To see the source code for this issue you must be a subscriber to Code of the Week. If you are a subscriber the source code is available at the following address: http://www.codeoftheweek.com/membersonly/bi/0106.html


This document is available on the web

Paid subscribers can view this issue in HTML format. There is no additional source or information in the HTML formatted document. It just looks a little better since we have included some HTML formatting. Just point your browser to link at the top of this document.

Get paid to surf the web!

If you would like to get paid for surfing the web, jump to http://www.codeoftheweek.com/paidsurf.html

Other links

Contact Information

C&D Programming Corp.
PO Box 20128
Floral Park, NY 11002-0128
Phone or Fax: (212) 504-7945
Email: info@codeoftheweek.com
Web: http://www.codeoftheweek.com