Advertisement
TheGamerTGT

FTP Upload [AutoIT]

Mar 22nd, 2016
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 2.03 KB | None | 0 0
  1. #include <FTPEx.au3>
  2. #include <Misc.au3>
  3. #include <EditConstants.au3>
  4. #include <GUIConstantsEx.au3>
  5. #include <ProgressConstants.au3>
  6. #include <WindowsConstants.au3>
  7. Global $sPath, $sFilename
  8. $sServer = "ftp.mozilla.org" ; or like your ftp server this is the Mozilla ftp server.
  9. $sUser = ""
  10. $sPassword = ""
  11. $hGUI = GUICreate("FTP Uploader", 320, 105, 192, 124)
  12. $hInput = GUICtrlCreateInput("", 8, 8, 217, 21)
  13. $hButton1 = GUICtrlCreateButton("Search File", 232, 6, 75, 25)
  14. $hButton2 = GUICtrlCreateButton("Upload", 8, 64, 75, 25)
  15. $hProgress = GUICtrlCreateProgress(8, 32, 297, 25)
  16. $hLabel = GUICtrlCreateLabel("", 91, 70, 200, 25)
  17. GUISetState(@SW_SHOW)
  18. While 1
  19.     $nMsg = GUIGetMsg()
  20.     Switch $nMsg
  21.         Case $GUI_EVENT_CLOSE
  22.             Exit
  23.         Case $hButton1
  24.             _file()
  25.         Case $hButton2
  26.             _Upload()
  27.     EndSwitch
  28. WEnd
  29. Func _file()
  30.     $sPath = FileOpenDialog("File search", @DesktopDir)
  31.     If @error Then Return
  32.     GUICtrlSetData($hInput, $sPath)
  33.     $aSplit = StringSplit($sPath, "\")
  34.     $sFilename = $aSplit[$aSplit[0]
  35. _Upload()
  36. EndFunc   ;==>_file
  37. Func _Upload()
  38.     If $sPath = "" Then
  39.         MsgBox(64, "Warning", "first file searching!")
  40.         Return
  41.     EndIf
  42.     $sReturn = MsgBox(4, "Upload?", "File" & $sPath & " upload?")
  43.     If $sReturn = 7 Then Return
  44.     $hOpen = _FTP_Open("FTP.Mozilla.org")
  45.     $hConnect = _FTP_Connect($hOpen, $sServer, $sUser, $sPassword, 1)
  46.     If @error Then
  47.         ProgressOff()
  48.         MsgBox(64, "Achtung", "Fail! (Serverdata not right??)")
  49.         _FTP_Close($hOpen)
  50.         _FTP_Close($hConnect)
  51.         Return
  52.     EndIf
  53.     _FTP_ProgressUpload($hConnect, $sPath, $sOrder&$sFilename, "_Update_Progress")
  54.     GUICtrlSetData($hProgress, 0)
  55.     GUICtrlSetData($hLabel, "")
  56.     If @error Then
  57.         ProgressOff()
  58.         MsgBox(64, "Warning", "Fail!")
  59.     Else
  60.         MsgBox(64, "Info", "Upload success!")
  61.     EndIf
  62.     _FTP_Close($hOpen)
  63.     _FTP_Close($hConnect)
  64. EndFunc   ;==>_Upload
  65. Func _Update_Progress($iProzent)
  66.     GUICtrlSetData($hProgress, $iProzent)
  67.     GUICtrlSetData($hLabel, "Upload at " & $iProzent & "% (stop with F8)")
  68.     If _IsPressed("77") Then Return 0
  69.     Return 1
  70. EndFunc   ;==>_Update_Progress
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement