Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

Upload file to ftp server in vbs

Source:

Set oShell = CreateObject("Shell.Application")
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Path to file or folder to upload
path = "C:\Users\%USERPROFILE%\Documents\filetoupload.txt"
FTPUpload(path)
Sub FTPUpload(path)
On Error Resume Next
'Copy Options: 16 = Yes to All
Const copyType = 16
'FTP Wait Time in ms
waitTime = 80000
FTPUser = "USERNAME"
FTPPass = "PASSWORD"
FTPHost = "FTPSERVER"
FTPDir = "/folder on ftp server to upload to"
strFTP = "ftp://" & FTPUser & ":" & FTPPass & "@" & FTPHost & FTPDir
Set objFTP = oShell.NameSpace(strFTP)
'Make new folder on FTP site
'objFTP.NewFolder "FTP Backup"
'Upload single file
If objFSO.FileExists(path) Then
Set objFile = objFSO.getFile(path)
strParent = objFile.ParentFolder
Set objFolder = oShell.NameSpace(strParent)
Set objItem = objFolder.ParseName(objFile.Name)
objFTP.CopyHere objItem, copyType
End If
'Upload all files in folder
If objFSO.FolderExists(path) Then
'Code below can be used to upload entire folder
Set objFolder = oShell.NameSpace(path)
objFTP.CopyHere objFolder.Items, copyType
End If
If Err.Number <> 0 Then
Wscript.Echo "Error: " & Err.Description
End If
'Wait for upload
WScript.Sleep waitTime
End Sub

Edit the values in green

Source/s Jacob, my friend and helper
thanks for share ! Good Job
(Nov 21, 2016 02:40 AM)Icoderz Wrote:  thanks for share ! Good Job
Thanks :)


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Shell] by HackooNov 24, 2021 11:20 PM 8 323 Nov 24, 2021 11:20 PM
Last Post: Louis Vuitton
[C] by gurlhackerclubAug 28, 2020 06:37 PM 5 198 Aug 28, 2020 06:37 PM
Last Post: gurlhackerclub
[C] by TerminallyIllNov 11, 2019 10:30 AM 6 285 Nov 11, 2019 10:30 AM
Last Post: HFDone