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

5.1k views Asked by At

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.

1

There are 1 answers

1
Martin Prikryl On BEST ANSWER

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)