2016-09-12 2 views
0

내가 파이썬에서 ftp를 사용하여 파일을 업로드하기 위해 노력하고있어,하지만 난라는 오류를 얻을 :파이썬 FTP 파일 이름에 잘못된 오류

ftplib.error_perm: 550 Filename invalid 

나는 다음과 같은 코드를 실행하면

ftp = FTP('xxx.xxx.x.xxx', 'MY_FTP', '') 
ftp.cwd("/incoming") 
file = open('c:\Automation\FTP_Files\MaxErrors1.json', 'rb') 
ftp.storbinary('STOR c:\Automation\FTP_Files\MaxErrors1.json', file) 
ftp.close() 

I을 파일이 내가 지정한 위치에 있는지 확인했는데 문제의 원인을 아는 사람이 있습니까?

답변

1

문제는 서버에서 경로 c:\Automation\FTP_Files\MaxErrors1.json이 유효하지 않다는 것입니다. 대신 일을 단지 시도 :

ftp.storbinary('STOR MaxErrors1.json', file) 
+0

감사합니다, 그것을 해결하는 – ChrisG29

0

STOR에 대한 인수는 원본 경로가 아닌 대상 파일 이름이어야합니다. ftp.storbinary('STOR MaxErrors1.json', file)을해야합니다.

0

당신은 예를 들어 FTP 서버 에 절대 경로없이 파일을 업로드해야합니다 도움을

import ftplib 
session = ftplib.FTP('server.address.com','USERNAME','PASSWORD') 
file = open('kitten.jpg','rb')     # file to send 
session.storbinary('STOR kitten.jpg', file)  # send the file 
file.close()         # close file and FTP 
session.quit() 
관련 문제