- Автор темы
- Добавить закладку
- #21
FTP Upload загрузка файлов по ftp
[CLIKE]
[/CLIKE]
[CLIKE]
C:
#include <FTPEx.au3>
#include <Misc.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <WindowsConstants.au3>
Global $sPath, $sFilename
$sServer = "ftp.mozilla.org" ; or like your ftp server this is the Mozilla ftp server.
$sUser = ""
$sPassword = ""
$hGUI = GUICreate("FTP Uploader", 320, 105, 192, 124)
$hInput = GUICtrlCreateInput("", 8, 8, 217, 21)
$hButton1 = GUICtrlCreateButton("Search File", 232, 6, 75, 25)
$hButton2 = GUICtrlCreateButton("Upload", 8, 64, 75, 25)
$hProgress = GUICtrlCreateProgress(8, 32, 297, 25)
$hLabel = GUICtrlCreateLabel("", 91, 70, 200, 25)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $hButton1
_file()
Case $hButton2
_Upload()
EndSwitch
WEnd
Func _file()
$sPath = FileOpenDialog("File search", @DesktopDir)
If @error Then Return
GUICtrlSetData($hInput, $sPath)
$aSplit = StringSplit($sPath, "\")
$sFilename = $aSplit[$aSplit[0]
_Upload()
EndFunc ;==>_file
Func _Upload()
If $sPath = "" Then
MsgBox(64, "Warning", "first file searching!")
Return
EndIf
$sReturn = MsgBox(4, "Upload?", "File" & $sPath & " upload?")
If $sReturn = 7 Then Return
$hOpen = _FTP_Open("FTP.Mozilla.org")
$hConnect = _FTP_Connect($hOpen, $sServer, $sUser, $sPassword, 1)
If @error Then
ProgressOff()
MsgBox(64, "Achtung", "Fail! (Serverdata not right??)")
_FTP_Close($hOpen)
_FTP_Close($hConnect)
Return
EndIf
_FTP_ProgressUpload($hConnect, $sPath, $sOrder&$sFilename, "_Update_Progress")
GUICtrlSetData($hProgress, 0)
GUICtrlSetData($hLabel, "")
If @error Then
ProgressOff()
MsgBox(64, "Warning", "Fail!")
Else
MsgBox(64, "Info", "Upload success!")
EndIf
_FTP_Close($hOpen)
_FTP_Close($hConnect)
EndFunc ;==>_Upload
Func _Update_Progress($iProzent)
GUICtrlSetData($hProgress, $iProzent)
GUICtrlSetData($hLabel, "Upload at " & $iProzent & "% (stop with F8)")
If _IsPressed("77") Then Return 0
Return 1
EndFunc ;==>_Update_Progress