by Ray Costanzo (1 Submission)
Category: Internet/HTML
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Mon 13th March 2000
Date Added: Mon 8th February 2021
Rating: (1 Votes)
An alternate FTP method.
API Declarations
''' ftp.exe is an application included with Windows NT 4,
''' Windows 2000, and Windows 98. You can quickly write
''' some commands and use that. This code is useful in a
''' controled environment in which you know all users will
''' have an internet connection, as this is just a quick,
''' alternate method.
Dim strTempDir As String
Dim strTempFtpFile As String
Dim strFileName As String
Dim strSiteAddress As String
Dim strUserName As String
Dim strPassword As String
Dim strRemoteDirectory As String
strSiteAddress = "www.yourdomain.com"
strUserName = "Username goes here"
strPassword = "Password goes here or assigned in some other way"
strRemoteDirectory = "upload directory, ie. wwwroot/path/path"
strTempDir = Environ("Temp")
If Len(strTempDir) = 0 Then strTempDir = "C:"
strTempFtpFile = strTempDir & "\fdty.l34"
strFileName = "C:\SomePath\SomeFileToUpload.xxx"
'''Write FTP commands into a file
Open strTempFtpFile For Output As #1
Print #1, "open " & strSiteAddress
Print #1, "user " & strUserName
Print #1, strPassword '''some servers may require "PW " & strPassword
'''but most automatically ask for it
Print #1, "type binary"
Print #1, "cd " & strRemoteDirectory
Print #1, "put " & strHtmlFileName
Print #1, "Quit"
Close #1
''' call ftp.exe with -n parameter, which will supress the automatic feedback
''' from the server, and -s which contains the path to the file to use for
''' ftp commands.
Call Shell("ftp -n -s:" & strTempFtpFile, vbHide)
End Sub