Lädt eine Datei im Binärmodus hoch und zeigt einen Fortschrittsbalken, bzw. ruft eine benutzerdefinierte Funktion auf
#include <FTPEx.au3>
_FTP_ProgressUpload ( $hFTPSession, $sLocalFile, $sRemoteFile [, $hFunctionToCall = 0] )
| $hFTPSession | Rückgabe von _FTP_Connect(). |
| $sLocalFile | Die lokale Datei. |
| $sRemoteFile | Die auf dem Server zu erzeugende Datei. |
| $hFunctionToCall | [optional] Eine Variable die mit der Benutzerfunktion verknüpft ist, um eine Forschrittsleiste zu aktualisieren oder auf Benutzerinteraktionen wie z. B. das abbrechen oder verlassen des Prozesses, zu reagieren. Standard = keine. Siehe Bemerkungen. |
| Erfolg: | 1 |
| Fehler: | 0 und setzt das @error Flag auf ungleich 0. |
| @error: | -1 - Die lokale Datei konnte nicht geöffnet werden -3 - Fehler beim Erzeugen der Datei -4 - Fehler beim Schreiben in die Datei -5 - Fehler beim Schließen der Datei -6 - Upload durch die Fortschrittsfunktion abgebrochen und Rückgabewert entspricht der aufgerufenen Funktion |
Informationen zu $hFunctionToCall:
Parameter: $iPercentage - Der Fortschritt in Prozent
Rückgabewerte:
Download fortsetzen - 1
Download abbrechen - 0 oder kleiner als 0 z. B. 0 oder -1
Diese Rückgabewerte werden dann von _FTP_ProgressUpload() zurückgegeben, sodass auf verschiedene Ereignisse wie Abbruch durch den Benutzer, Beenden des Programms oder TimeOut des Prozesses reagiert werden kann.
#include <FTPEx.au3>
#include <GUIConstantsEx.au3>
#include <Misc.au3>
#include <ProgressConstants.au3>
; This example NEED TO BE ADAPTED to valid $g_sRemoteFile/$sServer/$sUsername/$sPass
;~ Global $g_sRemoteFile = "pub/papers/graphics/research/skin.qt"
Global $g_sRemoteFile = "upload/temp.tmp"
Global $g_sLocalFile = @TempDir & "\temp.tmp"
;~ Local $sServer = 'ftp.cs.brown.edu' ; Brown Computer Science
Local $sServer = 'speedtest.tele2.net' ; Tele2 Speedtest Service
Local $sUsername = ''
Local $sPass = ''
Local $hInternetSession = _FTP_Open('MyFTP Control')
; passive allows most protected FTPs to answer
Local $hFTPSession = _FTP_Connect($hInternetSession, $sServer, $sUsername, $sPass, 1)
Example()
_FTP_Close($hInternetSession)
Func Example()
Local $fuFunctionToCall = _UpdateProgress
ProgressOn("Upload Progress", $g_sRemoteFile)
_FTP_ProgressUpload($hFTPSession, $g_sLocalFile, $g_sRemoteFile, $fuFunctionToCall)
ProgressOff()
EndFunc ;==>Example
Func _UpdateProgress($iPercent)
ProgressSet($iPercent, $iPercent & "%")
If _IsPressed("77") Then Return 0 ; Abort on F8
Return 1 ; Continue upload
EndFunc ;==>_UpdateProgress
#include <FTPEx.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
; This example NEED TO BE ADAPTED to valid $g_sRemoteFile/$sServer/$sUsername/$sPass
;~ Global $g_sRemoteFile = "pub/papers/graphics/research/skin.qt"
Global $g_sRemoteFile = "upload/temp.tmp"
Global $g_sLocalFile = @TempDir & "\temp.tmp"
;~ Local $sServer = 'ftp.cs.brown.edu' ; Brown Computer Science
Local $sServer = 'speedtest.tele2.net' ; Tele2 Speedtest Service
Local $sUsername = ''
Local $sPass = ''
Local $hInternetSession = _FTP_Open('MyFTP Control')
; passive allows most protected FTPs to answer
Local $hFTPSession = _FTP_Connect($hInternetSession, $sServer, $sUsername, $sPass, 1)
Global $g_idProgress_BarCtrl, $g_idBtn_Cancel
Example()
_FTP_Close($hInternetSession)
Func Example()
; create GUI
GUICreate("My GUI upload Progressbar", 220, 100, 100, 200)
GUICtrlCreateLabel($g_sRemoteFile, 10, 10)
$g_idProgress_BarCtrl = GUICtrlCreateProgress(10, 40, 200, 20, $PBS_SMOOTH)
GUICtrlSetColor(-1, 32250) ; not working with Windows XP Style
$g_idBtn_Cancel = GUICtrlCreateButton("Cancel", 75, 70, 70, 20)
GUISetState(@SW_SHOW)
Local $fuFunctionToCall = _UpdateGUIProgressBar
_FTP_ProgressUpload($hFTPSession, $g_sLocalFile, $g_sRemoteFile, $fuFunctionToCall)
Exit @error
EndFunc ;==>Example
Func _UpdateGUIProgressBar($iPercent)
GUICtrlSetData($g_idProgress_BarCtrl, $iPercent)
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Return -1 ; _FTP_UploadProgress Aborts with -1, so you can exit your app afterwards
Case $g_idBtn_Cancel
Return -2 ; Just Cancel, without special Return value
EndSwitch
Return 1 ; Otherwise continue Upload
EndFunc ;==>_UpdateGUIProgressBar