#Include <FTP.au3>
Const $Host = ''
Const $Login = ''
Const $Password = ''
Const $LocalFile = 'C:\WINDOWS\Notepad.exe'
Const $RemoteFile = 'Notepad.exe'
Const $INTERNET_STATUS_REQUEST_SENT = 31
Global $hFtp, $hSession, $Bytes = -32
ProgressOn('Uploading...', $LocalFile, '', -1, -1, 2)
_FTP_Startup()
$hFtp = _FTP_Open('MyFtp')
$tData = DllStructCreate('dword')
DllStructSetData($tData, 1, FileGetSize($LocalFile))
$hProc = DllCallbackRegister('_InternetStatus', 'none', 'ptr;ptr;dword;ptr;dword')
DllCall($WININET_DLL, 'ptr', 'InternetSetStatusCallback', 'ptr', $hFtp, 'ptr', DllCallbackGetPtr($hProc))
$hSession = _FTP_Connect($hFtp, $Host, $Login, $Password)
_FTP_PutFile($hSession, $LocalFile, $RemoteFile, 0, DllStructGetPtr($tData))
If @error Then
MsgBox(16, 'Error', ':(')
EndIf
_FTP_Disconnect($hSession)
DllCall($WININET_DLL, 'ptr', 'InternetSetStatusCallback', 'ptr', $hFtp, 'ptr', 0)
DllCallbackFree($hProc)
_FTP_Close($hFtp)
_FTP_Shutdown()
ProgressOff()
Func _InternetStatus($hSession, $hContext, $iStatus, $hInformation, $iLenght)
Switch $iStatus
Case $INTERNET_STATUS_REQUEST_SENT
Local $tFull = DllStructCreate('dword', $hContext)
Local $tSize = DllStructCreate('dword', $hInformation)
$Bytes += DllStructGetData($tSize, 1)
If $Bytes > 0 Then
ProgressSet($Bytes / DllStructGetData($tFull, 1) * 100)
EndIf
EndSwitch
EndFunc ;==>_InternetStatus