Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <FTPEx.au3>
- #include <Misc.au3>
- #include <ProgressConstants.au3>
- #include <GUIConstantsEx.au3>
- $s_LocalFile = FileOpenDialog ( "title", "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}", "All Files (*.*)")
- $sRemoteFile = StringRegExpReplace($s_LocalFile, ".+\\(.*\..*)$", "/$1")
- Local $sServer = ''
- 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 $idProgressBarCtrl, $idBtn_Cancel
- _uploadProgress()
- _FTP_Close($hInternetSession)
- Func _uploadProgress()
- ; create GUI
- GUICreate("FTP Upload", 220, 100, 100, 200)
- GUICtrlCreateLabel("Uploading: " & $sRemoteFile, 10, 10)
- $idProgressBarCtrl = GUICtrlCreateProgress(10, 40, 200, 20, $PBS_SMOOTH)
- GUICtrlSetColor(-1, 32250); not working with Windows XP Style
- $idBtn_Cancel = GUICtrlCreateButton("Cancel", 75, 70, 70, 20)
- GUISetState()
- Local $sFunctionToCall = "_UpdateGUIProgressBar"
- _FTP_ProgressUpload($hFTPSession, $s_LocalFile, $sRemoteFile, $sFunctionToCall)
- Exit @error
- EndFunc ;==>Example
- Func _UpdateGUIProgressBar($iPercent)
- GUICtrlSetData($idProgressBarCtrl, $iPercent)
- Switch GUIGetMsg()
- Case $GUI_EVENT_CLOSE
- Return -1 ; _FTP_UploadProgress Aborts with -1, so you can exit your app afterwards
- Case $idBtn_Cancel
- Return -2 ; Just Cancel, without special Return value
- EndSwitch
- Return 1 ; Otherwise continue Upload
- EndFunc ;==>_UpdateGUIProgressBar
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement