Advertisement
Guest User

Untitled

a guest
May 4th, 2017
567
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. fn uploadFileByFTP FTPpath file user: pass: = (
  2. FTP = dotNetObject "System.Net.WebClient"
  3.  
  4. local pathChunks = filterString FTPpath "/"
  5.  
  6. local FTPdomain
  7. if (pathChunks[1] == "ftp:") then ( FTPdomain = pathChunks[2] )
  8. else ( FTPdomain = pathChunks[1] )
  9. FTP.baseAddress = "ftp://" + FTPdomain + "/"
  10.  
  11. local FTPtarget = ""
  12. if (pathChunks[3] != undefined) then (
  13. for i = 3 to (pathChunks.count - 1) do (
  14. append FTPtarget (pathChunks[i] + "/" )
  15. )
  16. append FTPtarget pathChunks[pathChunks.count]
  17. if (FTPpath[FTPpath.count] == "/") then ( append FTPtarget ("/" + (filenameFromPath file)) )
  18. )
  19. else (
  20. FTPtarget = filenameFromPath file
  21. )
  22.  
  23. FTP.credentials = (dotNetObject "System.Net.NetworkCredential")
  24. FTP.credentials.username = if (user != unsupplied) then ( user ) else ( "anonymous" )
  25. FTP.credentials.password = if (pass != unsupplied) then ( pass ) else ( "ano@nym.us" )
  26.  
  27. FTP.uploadFile FTPtarget file
  28. FTP.dispose()
  29. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement