Ich bin momentan dabei mich in Python einzuarbeiten und möchte mir gerne ein Upload-GUI erstellen.
Allerdings habe ich da momentan ein par probleme.
Undzwar werden die flv Dateien nicht korrekt hochgeladen. Kleiner Dateien, wie zb txt oder py, scheinen komplett gochgeladen zu werden.
Ich habe ftp.storbinary und ftp.storlines ausprobiert, aber leider funktionieren beide nicht richtig.
Code: Alles auswählen
from Tkinter import *
from ftplib import FTP
from tkFileDialog import *
import tkMessageBox
import os
def Videodatei():
global myPath, myFile
myPath = askopenfilename(filetypes=[("Flash Video Files", "flv")])
print myPath
myDir, myFile = os.path.split(myPath)
print myDir
print myFile
entDatei.delete(0,END)
entDatei.insert(END, myPath)
def Upload():
ftp = FTP("HOST")
ftp.login("USER", "PW")
try:
f = open(myPath, "r")
ftp.cwd("pub")
ftp.storbinary("STOR " + myFile, f)
ftp.quit()
f.close()
except:
tkMessageBox.showwarning('Achtung','Es ist ein Fehler aufgetreten!')
root=Tk()
root.title("GTS Uploader")
root.geometry("500x250")
labDatei=Label(root,text=u"Datei")
labDatei.pack()
entDatei=Entry(root,width=60)
entDatei.pack()
butVideodatei=Button(root,text="Datei w\xe4hlen",command=Videodatei)
butVideodatei.pack()
butFertig=Button(root,text="Fertig",command=Upload)
butFertig.pack()
root.mainloop()
Danke schonmal