Posted By

goo on 08/27/08


Tagged

upload FTP access


Versions (?)

ACCESS FTP Upload


 / Published in: Visual Basic
 

URL: http://www.myaccesstips.com/Functionality/ftp.html

  1. Function FTP_Data()
  2. '=========================================================================
  3. 'FTP from Microsoft Access
  4. 'by Matthew V Carmichael
  5. 'Craetes FTP Batch File, FTP command file (txt)
  6. 'Default directory location of files to upload/download is
  7. 'the same location as the mdb file that contains this module.
  8. '========================================================================='
  9. On Error GoTo Err_Trap
  10.  
  11. Dim pFile As Long
  12. Dim strPath As String
  13. Dim strFileName As String
  14. Dim ftpServer As String
  15. Dim strUserName As String
  16. Dim strPassword As String
  17.  
  18. 'Path and Name of file to FTP
  19. strPath = CurrentProject.Path & "\"
  20. strFileName = "Test.mdb" 'Name of file to upload
  21. 'FTP Server Settings
  22. ftpServer = "Your FTP Server"
  23. strUserName = "Your FTP User Name"
  24. strPassword = "Your FTP Password"
  25.  
  26. 'Create text file containing FTP commands
  27. pFile = FreeFile
  28. Open strPath & "FTP_cmd.txt" For Output As pFile
  29. Print #pFile, "user"
  30. Print #pFile, strUserName
  31. Print #pFile, strPassword
  32. Print #pFile, "Put " & strFileName
  33. 'Use the Put command to upload, use the Get command to download.
  34. 'Print #pFile, "Get " & "Your File Name"
  35. Print #pFile, "quit"
  36. Close pFile
  37.  
  38. 'Create batch file to execute FTP
  39. pFile = FreeFile
  40. Open strPath & "FTP_Run.bat" For Output As pFile
  41. Print #pFile, "ftp -n -s:" & "FTP_cmd.txt " & ftpServer
  42. Print #pFile, "Pause"
  43. Close pFile
  44.  
  45. 'Execute FTP command
  46. Shell strPath & "FTP_Run.bat", 1
  47.  
  48. Err_Trap_Exit:
  49. Exit Function
  50.  
  51. Err_Trap:
  52. MsgBox Err.Number & " - " & Err.Description
  53. Resume Err_Trap_Exit
  54.  
  55. End Function

Report this snippet  

You need to login to post a comment.