0
下面是我有的代碼,它引用了一個未顯示的類。 class_connector只是提供一個模板來收集連接證書。試圖用ftplib上傳,可以很好地連接,但我在某個時間點搞砸了一些東西。
import connect_class
from ftplib import FTP
import os
account = connect_class.connector(raw_input('enter your hostname: '),
raw_input('enter your user name: '),
raw_input('enter your password: '),
raw_input('enter your directory: '))
ftp = FTP(account.host)
ftp.login(user=account.user, passwd=account.password)
ftp.retrlines('LIST')
def upload(ftp, file):
ext = os.path.splitext(file)[1]
if ext in (".txt", ".htm", ".html"):
ftp.storlines("STOR " + file, open(file))
else:
ftp.storbinary("STOR " + file, open(file, "rb"), 1024)
upload(ftp, '/file/somefile/file')