Jump to content

[SOLVED] _FTP_FilePut error / strange behaviour


Recommended Posts

The following function successfully connects to and uploads a local text file named user.dat

I have checked the data being written to the text file when it is created locally using a MsgBox and it appears exactly how it should be written to the file. If I comment out the FileDelete and go and open the file locally it is as expected.

However when I download the file from the FTP server and open it up the text that should be at the end of the file is missing. With each subsequent run more characters are missing.

I added the Sleep(5000) in case the function was closing the FTP connection too quickly before the file could be fully written but it makes no difference. The user.dat file is (should be) approximately 100 bytes so it is tiny.

Any idea why this is happening?

Func UpdateUserData() ; Upload the modified user.dat file
    Local $hOpen = _FTP_Open("myftp")
    Local $hConn = _FTP_Connect($hOpen, "my.ftp.server", "user", "pass", 1, 0, 1, 2)
    If @error Then
        MsgBox(16, "Error", "Connection failed" & @CRLF & @CRLF & "Please contact support")
        _FTP_Close($hConn)
        _FTP_Close($hOpen)
        Exit
    EndIf
    _FTP_FilePut($hConn, @TempDir & "\user.dat", "user.dat") ; Upload the new user.dat file
    Sleep(5000)
    If @error <> 0 Then
        MsgBox(16, "Error", "Couldn't transmit data" & @CRLF & @CRLF & "Please contact support")
        _FTP_Close($hConn)
        _FTP_Close($hOpen)
        Exit
    EndIf
    _FTP_Close($hConn)
    _FTP_Close($hOpen)
    FileDelete(@TempDir & "\user.dat")
EndFunc

 

Edited by Dent
solved
Link to comment
Share on other sites

Link to comment
Share on other sites

  • Jos locked this topic
Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...