user8528838
user8528838

Reputation:

Getting "500 Unknown command" when uploading a file to FTP in Python with FTP.storbinary

I am trying to upload a file to FTP. I am trying to upload a file to /public_html on files.000webhost.com but I keep getting ftplib.error_perm: 500 Unknown command

My code is below:

import ftplib
session = ftplib.FTP('files.000webhost.com','hazaaay','dwadawdadw')
file = r'C:\\Users\\Downloads\\A csv\\a csv1.csv','b'                  # file to send
session.storbinary('a csv1.csv', file)     # send the file
file.close()                                    # close file and FTP
session.quit()

Despite giving unresolved reference, it says in console that process finished with exit code 0 though it is not showing up in FileZilla. Any ideas? Thanks.

Upvotes: 5

Views: 5582

Answers (1)

Martin Prikryl
Martin Prikryl

Reputation: 202282

You have to specify the command in the FTP.storbinary call.

Store a file in binary transfer mode. command should be an appropriate STOR command: "STOR filename".

session.storbinary('STOR a csv1.csv', file)  

Upvotes: 4

Related Questions