acarter Posted February 17, 2014 Posted February 17, 2014 Hi all! So I have the below code, which works perfectly, but it uploads the entire contents of a folder to my server. How would I go about modifying it to take a file in a folder and upload it (rather than the whole folder's contents)? Thanks in advance! expandcollapse popup#Include <FTPEx.au3> FTP() Func FTP() Local $FTPOpen, $FTPConnect, $FTPServer Local $User, $Pass, $InstallFolder Local $FTPlocation, $FTPUpload, $FTPName Local $flag, $INIlocation = "UpdateConfig.ini" $flag = 0 $FTPName = IniRead($INIlocation, "1", "FTP Site", "") $FTPServer = IniRead($INIlocation, "1", "Server Name", "My FTP Site") $User = IniRead($INIlocation, "1", "Username", "My Username") $Pass = IniRead($INIlocation, "1", "Password", "My Password") $FTPlocation = IniRead($INIlocation, "1", "FTP Location", "/test/") ConsoleWrite("Name: " & $FTPName & " Server: " & $FTPServer & " User: " & $User & " Pass: " & $Pass & " Remote location: " & $FTPlocation) $FTPOpen = _FTP_Open($FTPName) $FTPConnect = _FTP_Connect($FTPOpen, $FTPServer, $User, $Pass, 1) If $FTPConnect <> 0 Then MsgBox(0, "Alert", "You must specify the path to the folder to upload", 20) $InstallFolder = ("C:\Folder\") If @error Then $flag = 1 EndIf If $flag = 1 Then MsgBox(0, "FTP", "No folder chosen.. Exiting.", 20) _FTP_Close($FTPOpen) Return EndIf $FTPUpload = _FTP_DirPutContents($FTPConnect, $InstallFolder, $FTPlocation, 1) If $FTPUpload <> 0 Then MsgBox(0, "FTP", "File(s) successfully uploaded!", 20) Else MsgBox(0, "FTP", "File(s) were not successfully uploaded! Check your FTP location and try again.", 10) EndIf Else MsgBox(0, "FTP", "Please check the FTP settings and try again. Error Code: " & $FTPConnect & " @error:" & @error, 100) EndIf _FTP_Close($FTPOpen) EndFunc
acarter Posted February 17, 2014 Author Posted February 17, 2014 Forgot to add, I changed DirPutContents to DirPutFile(with correct parameters) and it errors out on upload - the error is "File(s) were not successfully uploaded" message box.
Solution acarter Posted February 17, 2014 Author Solution Posted February 17, 2014 Fixed it. Needed to change the path to upload to include the file name and not just the directory.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now