Hallo,
ich habe hier ein kleines Skript vorhanden.
Dieses soll nach Auswahl einer Datei diese auf meinen FTP Hochladen...
XAMPP .. =D
Btw: Welche Ports braucht das Uploaden??
Mein Skript:
[autoit]#include <GUIConstants.au3>
#include <Array.au3>
#include <string.au3>
#include <INet.au3>
#Include <file.au3>
; Url zum Webverzeichnis
Dim $ServerUrl = "http://****************/Files/"
;Dim $ServerUrl = "http://testuser:qwert@http://www.kroegers-web.de/testdaten/"
; Dateiliste die runtergeladen werden soll
Dim $FileList = "files.txt"
;Speicherpfad für die Liste
Dim $SaveFileList = @TempDir & "\files.txt"
;Textdatei laden
If InetGet($ServerUrl & $FileList, $SaveFileList, 1) = 0 Then
MsgBox(48, "Fehlr...", "Fehler beim download der Dateiliste")
Exit 1
EndIf
;Dateiliste zum lesen öffnen
Dim $fso = FileOpen($SaveFileList, 0)
;Inhalt der Datei einlesen
Dim $txt = FileRead($fso)
;Dateiliste schliessen
FileClose($fso)
;@CRLF aus der $txt Variabele entfernen
$txt = StringReplace($txt, @CRLF, "|")
;##################################
; Variables
;##################################
$SmtpServer = "smtp.googlemail.com" ; address for the smtp-server to use - REQUIRED
$FromName = "MusicLoader" ; name from who the email was sent
$FromAddress = "*******" ; address from where the mail should come
$ToAddress = "**********" ; destination address of the email - REQUIRED
$Subject = "Neuer Titel!" ; subject from the email - can be anything you want it to be
$Body = "Nachrichtentext" ; the messagebody from the mail - can be left blank but then you get a blank mail
$AttachFiles = "" ; the file you want to attach- leave blank if not needed
$CcAddress = "" ; address for cc - leave blank if not needed
$BccAddress = "" ; address for bcc - leave blank if not needed
$Importance = "Normal" ; Send message priority: "High", "Normal", "Low"
$Username = "***********" ; username for the account used from where the mail gets sent - REQUIRED
$Password = "*******" ; password for the account used from where the mail gets sent - REQUIRED
;~ $IPPort = 25 ; port used for sending the mail
;~ $ssl = 0 ; enables/disables secure socket layer sending - put to 1 if using httpS
$IPPort=465 ; GMAIL port used for sending the mail
$ssl=1 ; GMAILenables/disables secure socket layer sending - put to 1 if using httpS
Global $oMyRet[2]
Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")
;#######################################
;Upload Variables
;#######################################
$server = 'bennes-music.no-ip.biz'
$username = '********'
$pass = '*******'
$txtList = StringSplit($txt, "|")
[/autoit][autoit][/autoit][autoit]$txt = ""
For $i = 1 To $txtList[0]
$txtlistlen = StringLen($txtList[$i]) + 1
$txtliststart = StringInStr($txtList[$i], "/") + 1
If $txtliststart = 0 Then
$txt = $txt & $i & "-" & $txtlist[$i] & "|"
Else
$txtlistcount = $txtlistlen - $txtliststart
$txtlistresult = StringMid($txtList[$i], $txtliststart, $txtlistcount)
$txt = $txt & $i & "-" & $txtlistresult & "|"
EndIf
Next
$txt = StringTrimRight($txt, 1)
[/autoit][autoit][/autoit][autoit];Form
$frmMain = GUICreate("Musik Loader", 285, 210, 993, 325)
$UploadButton = GUICtrlCreateButton ("Upload", 24, 185, 234, 25, 0)
$SongAskInput = GUICtrlCreateInput ("Welches Lied fehlt?", 24, 132, 233, 20, 0)
$SongAskSend =GUICtrlCreateButton ("Absenden", 24, 155, 234, 25, 0)
$pcbDownload = GUICtrlCreateProgress(24, 64, 233, 17)
$infoLabel = GUICtrlCreateLabel("", 24, 84, 233, 25);, $SS_CENTER )
$cmdButton = GUICtrlCreateButton("Start Download", 24, 103, 233, 25, 0)
GUICtrlSetState(-1, $GUI_DISABLE)
$FileList = GUICtrlCreateCombo("FileList", 24, 24, 233, 25)
GUICtrlSetData(-1, $txt)
GUISetState(@SW_SHOW)
[/autoit][autoit][/autoit][autoit];Variable für die derzeit Ausgewählte Datei
Dim $selectet
;Variable für die Dateiendung
Dim $mediaformat
;Speicherort
Dim $SaveFile
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $cmdButton
$SaveFile = FileSaveDialog("Datei Speichern...", @DesktopDir, "Musik (*." & $mediaformat & ")", 2, GUICtrlRead($FileList))
If Not @error Then RunDownload()
Case $FileList
GUICtrlSetData($infoLabel,"")
$id = StringLeft(GUICtrlRead($FileList),StringInStr(GUICtrlRead($FileList),"-")- 1)
$selectet = $ServerUrl & $txtList[$id]
InetGetSize($selectet)
If @error Then
GUICtrlSetState($cmdButton, $GUI_DISABLE)
Else
GUICtrlSetState($cmdButton, $GUI_ENABLE)
EndIf
$mediaformat = StringRight(GUICtrlRead($FileList), 3)
Case $SongAskSend
$rc = _INetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, "Hey, der neue Titel:" & GUICtrlRead($SongAskInput), $AttachFiles, $CcAddress, $BccAddress, $Importance, $Username, $Password, $IPPort, $ssl)
If @error Then
MsgBox(0, "Error!", "E-mail konnte nicht gesandt werden!")
Else
MsgBox(0, "Song Mail!", "Die E-mail wurde erfolgreich versand an:" & $ToAddress)
EndIf
Case $UploadButton
$sFile=FileOpenDialog("Datei öffnen", @ScriptDir, 'Alle Dateien (*.*)')
$Open = _FTPOpen('Bennes-Music Control')
$Conn = _FTPConnect($Open, $server, $username, $pass)
$Ftpp = _FtpPutFile($Conn, $sFile, '/Files/')
$Ftpc = _FTPClose($Open)
EndSwitch
WEnd
Func RunDownload()
GUISetState(@SW_DISABLE)
$FileSize = InetGetSize($selectet)
InetGet($selectet, $SaveFile, 1, 1)
$curSize = 0
Do
GUICtrlSetData($pcbDownload, $curSize)
$curFileSize = FileGetSize($SaveFile)
$curSize = $curFileSize * 100
$curSize = $curSize / $FileSize
$curSize = Ceiling($curSize)
$curFileSize = Round($curFileSize / 1024 / 1024, 2)
GUICtrlSetData($infoLabel, $curFileSize & " - " & Round($FileSize / 1024 / 1024, 2) & " MB (" & $curSize & "%)")
Sleep(200)
Until $curSize >= 99
GUISetState(@SW_ENABLE)
GUICtrlSetData($infoLabel, "Download beendet!!!")
GUICtrlSetData($pcbDownload, 0)
EndFunc ;==>RunDownload
; The UDF
Func _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject = "", $as_Body = "", $s_AttachFiles = "", $s_CcAddress = "", $s_BccAddress = "", $s_Importance="Normal", $s_Username = "", $s_Password = "", $IPPort = 25, $ssl = 0)
Local $objEmail = ObjCreate("CDO.Message")
$objEmail.From = '"' & $s_FromName & '" <' & $s_FromAddress & '>'
$objEmail.To = $s_ToAddress
Local $i_Error = 0
Local $i_Error_desciption = ""
If $s_CcAddress <> "" Then $objEmail.Cc = $s_CcAddress
If $s_BccAddress <> "" Then $objEmail.Bcc = $s_BccAddress
$objEmail.Subject = $s_Subject
If StringInStr($as_Body, "<") And StringInStr($as_Body, ">") Then
$objEmail.HTMLBody = $as_Body
Else
$objEmail.Textbody = $as_Body & @CRLF
EndIf
If $s_AttachFiles <> "" Then
Local $S_Files2Attach = StringSplit($s_AttachFiles, ";")
For $x = 1 To $S_Files2Attach[0]
$S_Files2Attach[$x] = _PathFull($S_Files2Attach[$x])
ConsoleWrite('@@ Debug(62) : $S_Files2Attach = ' & $S_Files2Attach & @LF & '>Error code: ' & @error & @LF) ;### Debug Console
If FileExists($S_Files2Attach[$x]) Then
$objEmail.AddAttachment ($S_Files2Attach[$x])
Else
ConsoleWrite('!> File not found to attach: ' & $S_Files2Attach[$x] & @LF)
SetError(1)
Return 0
EndIf
Next
EndIf
$objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
$objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $s_SmtpServer
If Number($IPPort) = 0 then $IPPort = 25
$objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = $IPPort
;Authenticated SMTP
If $s_Username <> "" Then
$objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
$objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = $s_Username
$objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $s_Password
EndIf
If $ssl Then
$objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
EndIf
;Update settings
$objEmail.Configuration.Fields.Update
; Set Email Importance
Switch $s_Importance
Case "High"
$objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "High"
Case "Normal"
$objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "Normal"
Case "Low"
$objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "Low"
EndSwitch
$objEmail.Fields.Update
; Sent the Message
$objEmail.Send
If @error Then
SetError(2)
Return $oMyRet[1]
EndIf
$objEmail=""
EndFunc ;==>_INetSmtpMailCom
;
;
; Com Error Handler
Func MyErrFunc()
$HexNumber = Hex($oMyError.number,
$oMyRet[0] = $HexNumber
$oMyRet[1] = StringStripWS($oMyError.description, 3)
ConsoleWrite("### COM Error ! Number: " & $HexNumber & " ScriptLine: " & $oMyError.scriptline & " Description:" & $oMyRet[1] & @LF)
SetError(1); something to check for when this function returns
Return
EndFunc ;==>MyErrFunc
Gibt es eine Möglichkeit noch einen Upload Balken (Fortschritt) zu schreiben?? Diesen dann darüber zu steztn?
(Positionieren kann ich alleine ;))
Jaaa..
Das sollte eben Funktionieren ..=)
Dann kann man auch Uploaden.. =)
Wenn dann eine Datei geuploaded ist, soll nur der Dateiname in Files.txt eingetragen werden.
Am besten wäre Alphabetische Reihenfolge. =)
Ist das überhaupt möglich??
Es tut mir Leid euch hier mit Fragen zuzumüllen =(
Mfg
Benne
Edit:
Mann könnte den Inhalt der files.txt auslesen und dann die files.txt löschen.
Dann eine neue Textdatei schreiben den Inhalt der ersten files.txt einfügen und dann den namen des neuen liedes einordnen.
Dann wieder hochladen.
Dann eine Meldung:"Fertig" zurückgeben..
Nur so ein Gedanke..^^
Edit2:
Ich weiß..
Ist Illegal!
Nur Test:
Für meinen Informatik Kurs.
Aufgabe: Einen funktionstüchtigen Uploader und Downloader machen
Musik ist dabei nur ein Beispiel da man ca. 3 MB große Dateien hat.
Der Sinn liegt im Unttericht
Also bitte nicht wegen Illegalheit meiden