The basic steps to create are:
1, call the InternetOpen function to set up the environment.
2, call the InternetConnect function to connect the host.
3, call the FtpPutFile function to get the file.
4, with the InternetCloseHandle function to close the 1th, 2-step handle.
When using FtpGetFile, it looks exactly the same as the steps above. The only difference, in fact, is to call FtpPutFile in step 3rd. VB specific call to this function declaration is:
Private Declare Function ftpputfile Lib "Wininet.dll" Alias "Ftpputfilea" _
(ByVal hftpsession as Long, ByVal Lpszlocalfile as String, _
ByVal Lpszremotefile as String, ByVal dwflags as Long, _
ByVal Dwcontext as Long) as Boolean
The first parameter hftpsession is the handle value returned by the InternetConnect call.
Lpsznewfile and Lpszremotefile are the file names on the local machine and the names of the files that will be created on the remote host.
The parameter dwflags is specified as 1 o'clock, the file is transferred in ASCII (Class A transmission method), and the specified 2 is a binary transfer file (1 class transmission method). Since DIRMAP.TXT is an ASCII text file, we pass the value 1.
Finally, when the callback signal is used, lcontext is used to identify the relationship between the applications. Because the callback signal is not used in our example, the value is 0.
The following is to get the DIRMAP.TXT file and C:\DIRMAP it. TXT call.
BLNRC = FtpPutFile (Lnginetconn, "C::\dirmap.txt", "Dirmap.txt", 1, 0)
If the function call succeeds, the BLNRC is True, and false instead.
As you can see, putting files on an FTP server is as easy as getting files from an FTP server. It is important to note that anonymous users do not have permission to create files on the FTP server. So make sure that the user account that you use to connect to the FTP server has permission to create files. Otherwise, the FtpPutFile function call returns FALSE, stating that the put failed.