Assume we'd like to upload files to FTP:\\192.168.1.12\Download storage\EXE\
from ftplib import FTP def upload_file_ToFTP(filename):
print 'upload:',filename ftp.storbinary('STOR Download storage\\EXE\\'+os.path.basename(filename), open(filename, 'rb')) #Initialize the FTP setting ftp = FTP('192.168.1.12') ftp.login(user='OOXX', passwd = 'SCRETE')
#get the current working directory cwd=os.getcwd() #get all files from the current working folder
files_list=os.listdir(cwd)
#upload files and skip directories for fn in files_list:
#get the full path file name _fn=os.path.realpath(fn)
#Skip directories if os.path.isdir(_fn): print 'Skip dir:',_fn continue upload_file_ToFTP(_fn)
#upload process completed, close FTP connection
ftp.close()
留言
張貼留言