Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fn uploadFileByFTP FTPpath file user: pass: = (
- FTP = dotNetObject "System.Net.WebClient"
- local pathChunks = filterString FTPpath "/"
- local FTPdomain
- if (pathChunks[1] == "ftp:") then ( FTPdomain = pathChunks[2] )
- else ( FTPdomain = pathChunks[1] )
- FTP.baseAddress = "ftp://" + FTPdomain + "/"
- local FTPtarget = ""
- if (pathChunks[3] != undefined) then (
- for i = 3 to (pathChunks.count - 1) do (
- append FTPtarget (pathChunks[i] + "/" )
- )
- append FTPtarget pathChunks[pathChunks.count]
- if (FTPpath[FTPpath.count] == "/") then ( append FTPtarget ("/" + (filenameFromPath file)) )
- )
- else (
- FTPtarget = filenameFromPath file
- )
- FTP.credentials = (dotNetObject "System.Net.NetworkCredential")
- FTP.credentials.username = if (user != unsupplied) then ( user ) else ( "anonymous" )
- FTP.credentials.password = if (pass != unsupplied) then ( pass ) else ( "ano@nym.us" )
- FTP.uploadFile FTPtarget file
- FTP.dispose()
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement