home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / HelpACoder45984132002.psc / Editor / Ftp_Upload.bas < prev    next >
Encoding:
BASIC Source File  |  2002-01-04  |  2.5 KB  |  57 lines

  1. Attribute VB_Name = "Ftp_Upload"
  2. 'Used for download
  3.     'used for downloading files
  4.     Public Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
  5.     '
  6. 'Needed to connect
  7.     Private Declare Function InternetOpen Lib "wininet" Alias "InternetOpenA" (ByVal sAgent As String, ByVal lAccessType As Long, ByVal sProxyName As String, ByVal sProxyBypass As String, ByVal lFlags As Long) As Long
  8.     '
  9. 'Connect
  10.     Private Declare Function InternetConnect Lib "wininet.dll" Alias "InternetConnectA" (ByVal hInternetSession As Long, ByVal sServerName As String, ByVal nServerPort As Integer, ByVal sUserName As String, ByVal sPassword As String, ByVal lService As Long, ByVal lFlags As Long, ByVal lContext As Long) As Long
  11.     '
  12. 'Close connection
  13.     Declare Function InternetCloseHandle Lib "wininet" (ByVal hInet As Long) As Integer
  14.     '
  15. 'Place a file
  16.     Declare Function FtpPutFile Lib "wininet.dll" Alias "FtpPutFileA" (ByVal hConnect As Long, ByVal lpszLocalFile As String, ByVal lpszNewRemoteFile As String, ByVal dwFlags As Long, ByVal dwContext As Long) As Boolean
  17.     '
  18.  
  19. 'Jest a few constants
  20.     Public Const INVALID_PORT = 0
  21.     Public Const OPEN_TYPE = 1
  22.     Public Const SERVICE_FTP = 1
  23.     Public Const FLAG_PASSIVE = &H8000000
  24.     Const FTP_BINARY = &H2
  25.  
  26. Public Sub PutFile()
  27. 'For Your Information
  28.     'This is not broken it will not work
  29.     'because you need a password the reason
  30.     'I still left the code is so you can learn
  31.     'from it though you need a site and and
  32.     'A correct password.
  33.     '
  34. 'Connet to ftp server
  35.     Ftp_hOpen = InternetOpen("vb wininet", INVALID_PORT, vbNullString, vbNullString, 0)
  36.     Ftp_Hconnection = InternetConnect(Ftp_hOpen, "www.jemisp.com", INVALID_PORT, "Visualcode", "server", SERVICE_FTP, FLAG_PASSIVE, 0)
  37.     '
  38. 'Tell them if it errors and exit sub
  39.     If Ftp_Hconnection = 0 Then MsgBox "Could not connect check and make sure your connected to the internet", vbCritical, "Error Connecting": Exit Sub
  40.     '
  41. 'Add file to site
  42.     'this is here just so i can see whats added
  43.     'just for filtering
  44.     FtpPutFile Ftp_Hconnection, "C:\tmp1.trsh", "want.rsd", FTP_BINARY, 0
  45.     'this adds it to the file
  46.     FtpPutFile Ftp_Hconnection, "C:\tmp2.trsh", "nrequest.rqst", FTP_BINARY, 0
  47.     '
  48. 'Close Connection
  49.     InternetCloseHandle Ftp_Hconnection
  50.     '
  51. 'delete files
  52.     Kill "C:\tmp1.trsh"
  53.     Kill "C:\tmp2.trsh"
  54. End Sub
  55.  
  56.  
  57.