FTP Upload geht nicht

  • Hey Leute.

    Ich habe mir bei BPLACED.net einen Webspace erstellt, und möchte nun per AutoIt, Dateien hochladen.

    Habe durch die SuFu eine nette UDF gefunden + Beispielscript. Jedoch klappt das nicht so wie ich will...

    [autoit]


    #include "FPT.au3"

    [/autoit][autoit][/autoit][autoit]

    $server = 'server'
    $username = 'user'
    $pass = 'pass'
    $UPLOADFILE = $log
    $FTPFILENAME = $log

    [/autoit][autoit][/autoit][autoit]

    $Open = _FTPOpen('Test')
    MsgBox(0,"",$Open)
    $Conn = _FTPConnect($Open, $server, $username, $pass)
    MsgBox(0,"",@error)
    $Ftpp = _FtpPutFile($Conn, $UPLOADFILE, $FTPFILENAME)
    MsgBox(0,"",$Ftpp)
    $Ftpc = _FTPClose($Open)
    MsgBox(0,"",$Ftpc)

    [/autoit]

    FTP.au3

    Spoiler anzeigen
    [autoit]

    ;===============================================================================
    ;
    ; Function Name: _FTPOpen()
    ; Description: Opens an FTP session.
    ; Parameter(s): $s_Agent - Random name. ( like "myftp" )
    ; $l_AccessType - I dont got a clue what this does.
    ; $s_ProxyName - ProxyName.
    ; $s_ProxyBypass - ProxyByPasses's.
    ; $l_Flags - Special flags.
    ; Requirement(s): DllCall, wininet.dll
    ; Return Value(s): On Success - Returns an indentifier.
    ; On Failure - 0 and sets @ERROR
    ; Author(s): Wouter van Kesteren.
    ;
    ;===============================================================================

    [/autoit] [autoit][/autoit] [autoit]

    Func _FTPOpen($s_Agent, $l_AccessType = 1, $s_ProxyName = '', $s_ProxyBypass = '', $l_Flags = 0)

    [/autoit] [autoit][/autoit] [autoit]

    Local $ai_InternetOpen = DllCall('wininet.dll', 'long', 'InternetOpen', 'str', $s_Agent, 'long', $l_AccessType, 'str', $s_ProxyName, 'str', $s_ProxyBypass, 'long', $l_Flags)
    If @error OR $ai_InternetOpen[0] = 0 Then
    SetError(-1)
    Return 0
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    Return $ai_InternetOpen[0]

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc ;==> _FTPOpen()

    [/autoit] [autoit][/autoit] [autoit]

    ;===============================================================================
    ;
    ; Function Name: _FTPConnect()
    ; Description: Connects to an FTP server.
    ; Parameter(s): $l_InternetSession - The Long from _FTPOpen()
    ; $s_ServerName - Server name/ip.
    ; $s_Username - Username.
    ; $s_Password - Password.
    ; $i_ServerPort - Server port ( 0 is default (21) )
    ; $l_Service - I dont got a clue what this does.
    ; $l_Flags - Special flags.
    ; $l_Context - I dont got a clue what this does.
    ; Requirement(s): DllCall, wininet.dll
    ; Return Value(s): On Success - Returns an indentifier.
    ; On Failure - 0 and sets @ERROR
    ; Author(s): Wouter van Kesteren
    ;
    ;===============================================================================

    [/autoit] [autoit][/autoit] [autoit]

    Func _FTPConnect($l_InternetSession, $s_ServerName, $s_Username, $s_Password, $i_ServerPort = 0, $l_Service = 1, $l_Flags = 0, $l_Context = 0)

    [/autoit] [autoit][/autoit] [autoit]

    Local $ai_InternetConnect = DllCall('wininet.dll', 'long', 'InternetConnect', 'long', $l_InternetSession, 'str', $s_ServerName, 'int', $i_ServerPort, 'str', $s_Username, 'str', $s_Password, 'long', $l_Service, 'long', $l_Flags, 'long', $l_Context)
    If @error OR $ai_InternetConnect[0] = 0 Then
    SetError(-1)
    Return 0
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    Return $ai_InternetConnect[0]

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc ;==> _FTPConnect()

    [/autoit] [autoit][/autoit] [autoit]

    ;===============================================================================
    ;
    ; Function Name: _FTPPutFile()
    ; Description: Puts an file on an FTP server.
    ; Parameter(s): $l_FTPSession - The Long from _FTPConnect()
    ; $s_LocalFile - The local file.
    ; $s_RemoteFile - The remote Location for the file.
    ; $l_Flags - Special flags.
    ; $l_Context - I dont got a clue what this does.
    ; Requirement(s): DllCall, wininet.dll
    ; Return Value(s): On Success - 1
    ; On Failure - 0
    ; Author(s): Wouter van Kesteren
    ;
    ;===============================================================================

    [/autoit] [autoit][/autoit] [autoit]

    Func _FTPPutFile($l_FTPSession, $s_LocalFile, $s_RemoteFile, $l_Flags = 0, $l_Context = 0)

    [/autoit] [autoit][/autoit] [autoit]

    Local $ai_FTPPutFile = DllCall('wininet.dll', 'int', 'FtpPutFile', 'long', $l_FTPSession, 'str', $s_LocalFile, 'str', $s_RemoteFile, 'long', $l_Flags, 'long', $l_Context)
    If @error OR $ai_FTPPutFile[0] = 0 Then
    SetError(-1)
    Return 0
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    Return $ai_FTPPutFile[0]

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc ;==> _FTPPutFile()

    [/autoit] [autoit][/autoit] [autoit]

    ;===============================================================================
    ;
    ; Function Name: _FTPDelFile()
    ; Description: Delete an file from an FTP server.
    ; Parameter(s): $l_FTPSession - The Long from _FTPConnect()
    ; $s_RemoteFile - The remote Location for the file.
    ; Requirement(s): DllCall, wininet.dll
    ; Return Value(s): On Success - 1
    ; On Failure - 0
    ; Author(s): Wouter van Kesteren
    ;
    ;===============================================================================

    [/autoit] [autoit][/autoit] [autoit]

    Func _FTPDelFile($l_FTPSession, $s_RemoteFile)

    [/autoit] [autoit][/autoit] [autoit]

    Local $ai_FTPPutFile = DllCall('wininet.dll', 'int', 'FtpDeleteFile', 'long', $l_FTPSession, 'str', $s_RemoteFile)
    If @error OR $ai_FTPPutFile[0] = 0 Then
    SetError(-1)
    Return 0
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    Return $ai_FTPPutFile[0]

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc ;==> _FTPDelFile()

    [/autoit] [autoit][/autoit] [autoit]

    ;===============================================================================
    ;
    ; Function Name: _FTPRenameFile()
    ; Description: Renames an file on an FTP server.
    ; Parameter(s): $l_FTPSession - The Long from _FTPConnect()
    ; $s_Existing - The old file name.
    ; $s_New - The new file name.
    ; Requirement(s): DllCall, wininet.dll
    ; Return Value(s): On Success - 1
    ; On Failure - 0
    ; Author(s): Wouter van Kesteren
    ;
    ;===============================================================================

    [/autoit] [autoit][/autoit] [autoit]

    Func _FTPRenameFile($l_FTPSession, $s_Existing, $s_New)

    [/autoit] [autoit][/autoit] [autoit]

    Local $ai_FTPRenameFile = DllCall('wininet.dll', 'int', 'FtpRenameFile', 'long', $l_FTPSession, 'str', $s_Existing, 'str', $s_New)
    If @error OR $ai_FTPRenameFile[0] = 0 Then
    SetError(-1)
    Return 0
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    Return $ai_FTPRenameFile[0]

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc ;==> _FTPRenameFile()

    [/autoit] [autoit][/autoit] [autoit]

    ;===============================================================================
    ;
    ; Function Name: _FTPMakeDir()
    ; Description: Makes an Directory on an FTP server.
    ; Parameter(s): $l_FTPSession - The Long from _FTPConnect()
    ; $s_Remote - The file name to be deleted.
    ; Requirement(s): DllCall, wininet.dll
    ; Return Value(s): On Success - 1
    ; On Failure - 0
    ; Author(s): Wouter van Kesteren
    ;
    ;===============================================================================

    [/autoit] [autoit][/autoit] [autoit]

    Func _FTPMakeDir($l_FTPSession, $s_Remote)

    [/autoit] [autoit][/autoit] [autoit]

    Local $ai_FTPMakeDir = DllCall('wininet.dll', 'int', 'FtpCreateDirectory', 'long', $l_FTPSession, 'str', $s_Remote)
    If @error OR $ai_FTPMakeDir[0] = 0 Then
    SetError(-1)
    Return 0
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    Return $ai_FTPMakeDir[0]

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc ;==> _FTPMakeDir()

    [/autoit] [autoit][/autoit] [autoit]

    ;===============================================================================
    ;
    ; Function Name: _FTPDelDir()
    ; Description: Delete's an Directory on an FTP server.
    ; Parameter(s): $l_FTPSession - The Long from _FTPConnect()
    ; $s_Remote - The Directory to be deleted.
    ; Requirement(s): DllCall, wininet.dll
    ; Return Value(s): On Success - 1
    ; On Failure - 0
    ; Author(s): Wouter van Kesteren
    ;
    ;===============================================================================

    [/autoit] [autoit][/autoit] [autoit]

    Func _FTPDelDir($l_FTPSession, $s_Remote)

    [/autoit] [autoit][/autoit] [autoit]

    Local $ai_FTPDelDir = DllCall('wininet.dll', 'int', 'FtpRemoveDirectory', 'long', $l_FTPSession, 'str', $s_Remote)
    If @error OR $ai_FTPDelDir[0] = 0 Then
    SetError(-1)
    Return 0
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    Return $ai_FTPDelDir[0]

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc ;==> _FTPDelDir()

    [/autoit] [autoit][/autoit] [autoit]

    ;===============================================================================
    ;
    ; Function Name: _FTPClose()
    ; Description: Closes the _FTPOpen session.
    ; Parameter(s): $l_InternetSession - The Long from _FTPOpen()
    ; Requirement(s): DllCall, wininet.dll
    ; Return Value(s): On Success - 1
    ; On Failure - 0
    ; Author(s): Wouter van Kesteren
    ;
    ;===============================================================================

    [/autoit] [autoit][/autoit] [autoit]

    Func _FTPClose($l_InternetSession)

    [/autoit] [autoit][/autoit] [autoit]

    Local $ai_InternetCloseHandle = DllCall('wininet.dll', 'int', 'InternetCloseHandle', 'long', $l_InternetSession)
    If @error OR $ai_InternetCloseHandle[0] = 0 Then
    SetError(-1)
    Return 0
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    Return $ai_InternetCloseHandle[0]

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc ;==> _FTPClose()

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ; ================================================= FTP Functions for UDF ==========================================================

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Local Const $FTP_ASCII = 1
    Local Const $FTP_BINARY = 2
    Local Const $FTP_OVERWRITE = 0
    Local Const $FTP_DONTOVERWRIRE = -1
    Local Const $FTP_PASSIVE = 0x8000000
    Local Const $FTP_NONPASSIVE = 0

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;===============================================================================

    [/autoit] [autoit][/autoit] [autoit]

    ;
    ; Function Name: _FTPFileFindFirst()
    ; Description: Find First File on an FTP server.
    ; Parameter(s): $l_FTPSession - The Long from _FTPConnect()
    ; $s_RemoteFile - The remote Location for the file.
    ; $l_Flags - use the dwFlags parameter to specify 1 for transferring the file in ASCII (Type A transfer method) or 2 for transferring the file in Binary (Type I transfer method).
    ; $l_Context - lContext is used to identify the application context when using callbacks. Since we’re not using callbacks we’ll pass 0.
    ; Requirement(s): DllCall, wininet.dll
    ; Return Value(s): On Success - 1
    ; On Failure - 0
    ; Author(s): Dick Bronsdijk
    ;
    ;===============================================================================

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    #cs
    typedef struct _WIN32_FIND_DATA {
    DWORD dwFileAttributes;
    FILETIME ftCreationTime;
    FILETIME ftLastAccessTime;
    FILETIME ftLastWriteTime;
    DWORD nFileSizeHigh;
    DWORD nFileSizeLow;
    DWORD dwReserved0;
    DWORD dwReserved1;
    TCHAR cFileName[MAX_PATH];
    TCHAR cAlternateFileName[14];
    } WIN32_FIND_DATA;
    typedef struct _FILETIME {
    DWORD dwLowDateTime;
    DWORD dwHighDateTime;
    } FILETIME;
    #ce
    Func _FTPFileFindFirst($l_FTPSession, $s_RemoteFile, ByRef $h_Handle, ByRef $l_DllStruct, $l_Flags = 0, $l_Context = 0)

    [/autoit] [autoit][/autoit] [autoit]

    Local $str = "int;uint[2];uint[2];uint[2];int;int;int;int;char[256];char[14]"
    $l_DllStruct = DllStructCreate($str)
    if @error Then
    SetError(-2)
    Return ""
    endif

    [/autoit] [autoit][/autoit] [autoit]

    Dim $a_FTPFileList[1]
    $a_FTPFileList[0] = 0

    [/autoit] [autoit][/autoit] [autoit]

    Local $ai_FTPPutFile = DllCall('wininet.dll', 'int', 'FtpFindFirstFile', 'long', $l_FTPSession, 'str', $s_RemoteFile, 'ptr', DllStructGetPtr($l_DllStruct), 'long', $l_Flags, 'long', $l_Context)
    If @error OR $ai_FTPPutFile[0] = 0 Then
    SetError(-1)
    Return $a_FTPFileList
    EndIf
    $h_Handle = $ai_FTPPutFile[0]
    $FileName = DllStructGetData($l_DllStruct, 9)

    [/autoit] [autoit][/autoit] [autoit]

    Dim $a_FTPFileList[12]
    $a_FTPFileList[0] = 12
    $a_FTPFileList[1] = DllStructGetData($l_DllStruct, 1) ; File Attributes
    $a_FTPFileList[2] = DllStructGetData($l_DllStruct, 2, 1) ; Creation Time Low
    $a_FTPFileList[3] = DllStructGetData($l_DllStruct, 2, 2) ; Creation Time High
    $a_FTPFileList[4] = DllStructGetData($l_DllStruct, 3, 1) ; Access Time Low
    $a_FTPFileList[5] = DllStructGetData($l_DllStruct, 3, 2) ; Access Time High
    $a_FTPFileList[6] = DllStructGetData($l_DllStruct, 4, 1) ; Last Write Low
    $a_FTPFileList[7] = DllStructGetData($l_DllStruct, 4, 2) ; Last Write High
    $a_FTPFileList[8] = DllStructGetData($l_DllStruct, 5) ; File Size High
    $a_FTPFileList[9] = DllStructGetData($l_DllStruct, 6) ; File Size Low
    $a_FTPFileList[10] = DllStructGetData($l_DllStruct, 9) ; File Name
    $a_FTPFileList[11] = DllStructGetData($l_DllStruct, 10) ; Altername

    [/autoit] [autoit][/autoit] [autoit]

    Return $a_FTPFileList

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc;==> _FTPFileFindFirst()

    [/autoit] [autoit][/autoit] [autoit]

    ;===============================================================================

    [/autoit] [autoit][/autoit] [autoit]

    ;
    ; Function Name: _FTPFileFindNext()
    ; Description: Find Next File on an FTP server.
    ; Parameter(s): $l_FTPSession - The Long from _FTPConnect()
    ; $s_RemoteFile - The remote Location for the file.
    ; Requirement(s): DllCall, wininet.dll
    ; Return Value(s): On Success - 1
    ; On Failure - 0
    ; Author(s): Dick Bronsdijk
    ;
    ;===============================================================================

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _FTPFileFindNext($h_Handle, $l_DllStruct)

    [/autoit] [autoit][/autoit] [autoit]

    Dim $a_FTPFileList[1]
    $a_FTPFileList[0] = 0

    [/autoit] [autoit][/autoit] [autoit]

    Local $ai_FTPPutFile = DllCall('wininet.dll', 'int', 'InternetFindNextFile', 'long', $h_Handle, 'ptr', DllStructGetPtr($l_DllStruct))
    If @error OR $ai_FTPPutFile[0] = 0 Then
    SetError(-1)
    Return $a_FTPFileList
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    Dim $a_FTPFileList[12]
    $a_FTPFileList[0] = 12
    $a_FTPFileList[1] = DllStructGetData($l_DllStruct, 1) ; File Attributes
    $a_FTPFileList[2] = DllStructGetData($l_DllStruct, 2, 1) ; Creation Time Low
    $a_FTPFileList[3] = DllStructGetData($l_DllStruct, 2, 2) ; Creation Time High
    $a_FTPFileList[4] = DllStructGetData($l_DllStruct, 3, 1) ; Access Time Low
    $a_FTPFileList[5] = DllStructGetData($l_DllStruct, 3, 2) ; Access Time High
    $a_FTPFileList[6] = DllStructGetData($l_DllStruct, 4, 1) ; Last Write Low
    $a_FTPFileList[7] = DllStructGetData($l_DllStruct, 4, 2) ; Last Write High
    $a_FTPFileList[8] = DllStructGetData($l_DllStruct, 5) ; File Size High
    $a_FTPFileList[9] = DllStructGetData($l_DllStruct, 6) ; File Size Low
    $a_FTPFileList[10] = DllStructGetData($l_DllStruct, 9) ; File Name
    $a_FTPFileList[11] = DllStructGetData($l_DllStruct, 10) ; Altername

    [/autoit] [autoit][/autoit] [autoit]

    Return $a_FTPFileList

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc;==> _FTPFileFindNext()

    [/autoit] [autoit][/autoit] [autoit]

    ;===============================================================================

    [/autoit] [autoit][/autoit] [autoit]

    ;
    ; Function Name: _FTPFileFindClose()
    ; Description: Delete FindFile Structure.
    ; Parameter(s):
    ; Requirement(s): DllCall, wininet.dll
    ; Return Value(s): On Success - 1
    ; On Failure - 0
    ; Author(s): Dick Bronsdijk
    ;
    ;===============================================================================

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _FTPFileFindClose($h_Handle, $l_DllStruct)

    [/autoit] [autoit][/autoit] [autoit]

    ;~ DllStructDelete($l_DllStruct)

    [/autoit] [autoit][/autoit] [autoit]

    Local $ai_FTPPutFile = DllCall('wininet.dll', 'int', 'InternetCloseHandle', 'long', $h_Handle)
    If @error OR $ai_FTPPutFile[0] = 0 Then
    SetError(-1)
    Return ""
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    Return $ai_FTPPutFile[0]

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc;==> _FTPFileFindClose()

    [/autoit] [autoit][/autoit] [autoit]

    ;===============================================================================
    ;
    ; Function Name: _FTPGetFile() - db Test
    ; Description: Gets an file from an FTP server.
    ; Parameter(s): $l_FTPSession - The Long from _FTPConnect()
    ; $s_RemoteFile - The remote Location for the file.
    ; $s_LocalFile - The local file.
    ; $l_Flags - use the dwFlags parameter to specify
    ; - 1 for transferring the file in ASCII (Type A transfer method) or
    ; - 2 for transferring the file in Binary (Type I transfer method).
    ; $l_Fail - Allow local file to be overwritten if it exists
    ; - -1 Don't allow overwrite (default)
    ; - 0 Allow overwrite
    ; $l_Attributes - Attributes for local file
    ; $l_Context - lContext is used to identify the application context when using callbacks. Since we’re not using callbacks we’ll pass 0.
    ; Requirement(s): DllCall, wininet.dll
    ; Return Value(s): On Success - 1
    ; On Failure - 0
    ; Author(s): Dick Bronsdijk
    ;
    ;===============================================================================

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _FTPGetFile($l_FTPSession, $s_RemoteFile, $s_LocalFile, $l_Flags = 2, $l_Fail = -1, $l_Attributes = 0, $l_Context = 0)

    [/autoit] [autoit][/autoit] [autoit]

    Local $ai_FTPGetFile = DllCall('wininet.dll', 'int', 'FtpGetFile', 'long', $l_FTPSession, 'str', $s_RemoteFile, 'str', $s_LocalFile, 'long', $l_Fail, 'long', $l_Attributes, 'long', $l_Flags, 'long', $l_Context)
    If @error OR $ai_FTPGetFile[0] = 0 Then
    SetError(-1)
    Return 0
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    Return $ai_FTPGetFile[0]

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc;==> _FTPGetFile()

    [/autoit]

    Soweit, sogut. Laut MsgBoxen treten die Fehler bei

    [autoit]

    $Conn = _FTPConnect($Open, $server, $username, $pass)
    $Ftpp = _FtpPutFile($Conn, $UPLOADFILE, $FTPFILENAME)

    [/autoit]

    auf. Laut UDF bedeuted 0 das ein Error vorliegt. Leider habe ich dazu keine Doc. wo ich sehe, was der Error bedeuted.

    Kennt sich jemand damit aus, und kann mir jemand helfen? Kennt vielleicht wer eine andere Methode, dateien auf einen FTP Server hochziladen?

  • Jetzt schaut es so aus:

    [autoit]


    $server = 'server'
    $username = 'user'
    $pass = 'pass'
    $UPLOADFILE = $log
    $FTPFILENAME = $log

    [/autoit][autoit][/autoit][autoit]

    $Open = _FTP_Open('Test')
    MsgBox(0,"",$Open)
    $Conn = _FTP_Connect($Open, $server, $username, $pass)
    MsgBox(0,"",@error)
    $Ftpp = _Ftp_FilePut($Conn, $UPLOADFILE, $FTPFILENAME)
    MsgBox(0,"",$Ftpp)
    $Ftpc = _FTP_Close($Open)
    MsgBox(0,"",$Ftpc)

    [/autoit]

    Die Messageboxen geben aus:

    0x00CC0004
    0
    0
    1

  • Offenbar geht _FTP_Connect schief.
    Hast du deine FTP-Zugangsdaten mal mit einem "richtigen" FTP-Programm, wie z.B. "FileZilla Client" ausprobiert ?
    Prüfe auch den Pfadnamen auf dem Server, ob du da überhaupt was hochladen darfst, wo du beim Einloggen landest.

    Wer andern eine Bratwurst brät
    der hat ein Bratwurstbratgerät.

  • @cinema

    was enthält denn deine variable $log?

    hier mal ein beispiel!

    [autoit][/autoit][autoit][/autoit][autoit]

    $server = 'server'
    $username = 'user'
    $pass = 'pass'

    [/autoit][autoit][/autoit][autoit]

    $path = '/'

    [/autoit][autoit][/autoit][autoit]

    $Open = _FTP_Open('server')
    $Conn = _FTP_Connect($Open, $server, $username, $pass, true)
    ;MsgBox(0,"",$Conn)
    $setdir = _Ftp_DirSetCurrent($Conn, $path)
    ;MsgBox(0,"set dir",$setdir)

    [/autoit][autoit][/autoit][autoit]

    ;$Dirlist = _FTPFilesListToArray($Conn, 1)
    ;_ArrayDisplay($Dirlist, 'Directorys List')

    [/autoit][autoit][/autoit][autoit]

    $Dirlist = _FTP_ListToArray2D($Conn, 2)
    ;MsgBox(0,"files vorhanden?",$Dirlist[0])
    ;_ArrayDisplay($Dirlist, 'File List')

    [/autoit][autoit][/autoit][autoit]

    If $Dirlist[0][0] = 0 Then
    MsgBox(0,"", "keine Files vorhanden",1)
    Exit
    Else
    For $i = 1 To $Dirlist[0][0]
    ;MsgBox(0,"files ++++",$Dirlist[$i][0])
    IF $Dirlist[$i][1] = 0 Then ;prüfung auf fehler
    ;MsgBox(0,"files ++++",$Dirlist[$i][1])
    Else
    $left = StringLeft($Dirlist[$i][0], 6)
    $right = StringRight($Dirlist[$i][0], 4)
    ;MsgBox(0,"",$left & $right)

    [/autoit][autoit][/autoit][autoit]

    IF $left = "agabda" And $right = ".dat" Then
    ;MsgBox(0,"",$Dirlist[$i][0])
    _FTP_FileGet($Conn, $Dirlist[$i][0], $Zielpfad & $Dirlist[$i][0]) ; lädt file vom ftp server
    Sleep(1000)
    _FTP_FileDelete($Conn, $Dirlist[$i][0]) ; löscht file vom ftp server
    Sleep(1000)
    _alltours_upload()
    Else
    ;MsgBox(0,"",$Dirlist[$i][0])
    _FileWriteLog(@ScriptDir & "\Temp\upload.log","Error - No dat File")
    EndIf
    EndIf
    Next
    EndIf

    [/autoit][autoit][/autoit][autoit]

    _FTP_Close($Open)

    [/autoit][autoit][/autoit][autoit][/autoit]

    gruß gmmg

  • So sollte es funktionieren:

    Spoiler anzeigen
    [autoit]


    #include<FTPEx.au3>
    $sServer = "username.bplaced.net"
    $sUsername = "username"
    $sPassword = "PASS1234"

    [/autoit] [autoit][/autoit] [autoit]

    $sSource = "C:\test.txt"
    $sTarget = "test.txt"

    [/autoit] [autoit][/autoit] [autoit]

    $hFTPClient = _FTP_Open('AutoItFTP v08.15')
    If $hFTPClient Then
    $hFTPConn = _FTP_Connect($hFTPClient, $sServer, $sUsername, $sPassword)
    If $Conn Then
    If _Ftp_FilePut($hFTPConn, $sSource, $sTarget) Then
    MsgBox(0, '', "Success")
    Else
    MsgBox(0, "Error on FilePut", @error)
    EndIf
    _FTP_Close($hFTPConn)
    Else
    MsgBox(0, 'Error on connect', @error)
    EndIf
    _FTP_Close($hFTPClient)
    Else
    MsgBox(0, 'Error on open', @error)
    EndIf

    [/autoit]
  • Bei mir funktioniert es, nur eine Variable war falsch benannt. Welche Dateipfade verwendest du denn?

    Spoiler anzeigen
    [autoit]

    #include<FTPEx.au3>
    $sServer = "BENUTZERNAME.bplaced.net"
    $sUsername = "BENUTZERNAME"
    $sPassword = "PASSWORT"

    [/autoit] [autoit][/autoit] [autoit]

    $sSource = "D:\start.bat"
    $sTarget = "test.txt"

    [/autoit] [autoit][/autoit] [autoit]

    $hFTPClient = _FTP_Open('AutoItFTP v08.15')
    If $hFTPClient Then
    $hFTPConn = _FTP_Connect($hFTPClient, $sServer, $sUsername, $sPassword)
    If $hFTPConn Then
    If _Ftp_FilePut($hFTPConn, $sSource, $sTarget) Then
    MsgBox(0, '', "Success")
    Else
    MsgBox(0, "Error on FilePut", @error)
    EndIf
    ;_FTP_FileDelete($hFTPConn, $sTarget)
    _FTP_Close($hFTPConn)
    Else
    MsgBox(0, 'Error on connect', @error)
    EndIf
    _FTP_Close($hFTPClient)
    Else
    MsgBox(0, 'Error on open', @error)
    EndIf

    [/autoit]
  • Das die eine Variable falsch verwendet wurde ist mir aufgefallen, das war ja nicht das Problem.

    Als Dateipfad:

    Die Datei liegt genau bei der Exe. Der Name ist in $log gespeichert.

    [autoit]


    $sSource = $log
    $sTarget = $log

    [/autoit][autoit][/autoit][autoit]

    $hFTPClient = _FTP_Open('AutoItFTP v08.15')
    If $hFTPClient Then
    $hFTPConn = _FTP_Connect($hFTPClient, $sServer, $sUsername, $sPassword)
    If $hFTPConn Then
    If _Ftp_FilePut($hFTPConn, $sSource, $sTarget) Then
    MsgBox(0, '', "Success")
    Else
    MsgBox(0, "Error on FilePut", @error)
    EndIf
    _FTP_Close($hFTPConn)
    Else
    MsgBox(0, 'Error on connect', @error)
    EndIf
    _FTP_Close($hFTPClient)
    Else
    MsgBox(0, 'Error on open', @error)

    [/autoit][autoit][/autoit][autoit][/autoit]


    EndIf

  • Was steht genau in $log? Vermutlich ist da ein Pfad drin, der auf dem FTP-Server nicht erlaubt ist oder so.
    Übrigens sollte kein Fehler bei _FTP_Open kommen, wenn du die Verbindungsdaten richtig eingegeben hast. Eventuell musst du noch den Passovmodus anstellen.

  • [autoit]

    Local $log = @UserName & " - " & $date & "-log.html"

    [/autoit]

    Das ist die Variable $log.

    Wenn ich nun den Passivmodus einschalte:

    [autoit]

    $hFTPConn = _FTP_Connect($hFTPClient, $sServer, $sUsername, $sPassword,1)

    [/autoit]

    kommt bei FilePut und Open "-1"

  • Ok, dann versuche es mal ohne Passivmodus und mit $sSource = @ScriptDir & "\" & $log
    Eine andere Idee habe ich nicht mehr, höchstens du gibst den falshcen Servernamen an oder so.

  • Also es hat sich nichts geändert. Beides immernoch -1.

    Habe auch andere Anmeldedaten probiert, es geht nicht... Mit Filezilla schon.