please help me with python ftplib. i was trying to copy files from my linux machine to a windows server using ftplib. everything was working good. but i'm only able to copy files from the same directory the script is. how do i copy files from a different directory? i always get "file not found error message". here's my code :
Code:
tester_name = str (socket.gethostname()) 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) parse_source_path = ('/path/to/where/i/go/') parse_source_file_list = os.listdir(parse_source_path) ftp = ftplib.FTP("server_IP") ftp.login("username", "pass") folder_list = [] ftp.dir(folder_list.append) if str(tester_name) not in str(folder_list) : ftp.mkd("%s"%tester_name) ftp.cwd("%s"%tester_name) for files in parse_source_file_list : print files upload(ftp, files) else : print "later"