InitNetwork()
If OpenFTP(0, "***", "***", "***") ;* hidden
Debug "FTP Connected"
; SetFTPDirectory() - only an immediate directory change is allowed.
; To change to several levels of directory, this command will have to be called several time.
; Eg. SetFtpDirectory(Connect, "pub/support") is invalid on most servers.
; Some servers require directory names to match on case, so take care.
ServerDirectory$ = "/www" ; replace with your information <<<<<<<------
For Ctr = 2 To CountString(ServerDirectory$, "/")+1
SetFTPDirectory(0, StringField(ServerDirectory$,Ctr,"/"))
Next
; Verifying server's current directory is correct. Some delay is necessary
While Directoryname$ = ""
Delay(50)
Directoryname$ = GetFTPDirectory(0)
Wend
Debug Directoryname$
Filename$ = "C:\PureBasic.chm"
Result = SendFTPFile(0, Filename$, GetFilePart(Filename$), #True)
Debug Result
If Result
Repeat
Delay(10)
Until FTPProgress(0) = #PB_FTP_Started ; -1
Debug "The file transfer has been initialized."
Repeat
Delay(10)
Result = FTPProgress(0)
Select Result
Case #PB_FTP_Error ; -2
Debug "Send/Recv error occurred."
Break
Case #PB_FTP_Finished ; -3
Debug FileSize(Filename$) ; should actually be verified against remote file here
Debug "The file transfer has finished."
Break
Default
; Show bytes tranferred
Debug Result + 1
EndSelect
ForEver
Delay(100)
CloseFTP(0)
EndIf
Else
MessageRequester("Error", "Can't connect to the FTP server")
EndIf
I should have noted for you that I removed the Active setting.
I haven't been successful using the FTP library to send/receive a file on an "Active" connection with either my Windows or Unix based servers. Not sure why. But since I only use "Passive" connections day to day, I just haven't worried about it.
AFAIK, the only problem that I still have with the FTP Library is the ExamineFTPDirectory() command when used with a UNIX/Linux based server where it delays for 3 minutes. That problem doesn't happen with my Windows based servers. I have reported this as a potential bug, but no reply so far.