Je rencontre une erreur d'upload dans le script ci-dessous.
Pourtant, je reçois bien un fichier sur mon ftp, mai celui-ci est vide.
► Afficher le texte
Code : Tout sélectionner
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <FTPEx.au3>
#include <File.au3>
Dim $functions[1] = ["test"]
Dim $Input1
Dim $data, $continue = 0
Dim $sServerName = "", $sUsername = "", $sPassword = "", $sLocalFile = @ScriptDir & "\local.txt", $sRemoteFile = "remote.txt"
$ftpOpen = _FTP_Open('ftp')
$ftpConnect = _FTP_Connect ($ftpOpen, $sServerName, $sUsername, $sPassword)
If @error Then
MsgBox(0, "", "Error : couldn't connect to the ftp server")
Else
_main()
EndIf
Func _main()
$Form1 = GUICreate("Client", 522, 74, @DesktopWidth / 2 - 261, @DesktopHeight / 2 - 37)
$Input1 = GUICtrlCreateInput("", 24, 24, 369, 21)
$Button1 = GUICtrlCreateButton("Send", 416, 24, 81, 25)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
_send()
EndSwitch
WEnd
EndFunc
Func _send()
$data = GUICtrlRead($Input1)
For $i = 0 To UBound($functions) - 1
If $data = $functions[$i] Then $continue = 1
Next
If $continue = 1 Then
If FileExists($sLocalFile) Then
FileDelete($sLocalFile)
_FileCreate($sLocalFile)
EndIf
FileWrite($sLocalFile, $data)
If @error Then
MsgBox(0, "Error", "Error : file writing")
Else
_FTP_FilePut ($ftpConnect, $sLocalFile, $sRemoteFile)
If @error Then MsgBox(0, "", "Error : file uploading")
EndIf
Else
MsgBox(0, "Error", "This function doesn't exist")
EndIf
GUICtrlSetData($Input1, "")
EndFunc




